Factorial
Factorial is the product of an integer and all the integers below it; for example, factorial four (4!)=1*2*3*4=24.
C# program for Factorial.
using System;
namespace Factorial
{
class Program
{
static void Main(string[] args)
{
int factorialNumber=1;
Console.Write("Please enter a number:");
int number = int.Parse(Console.ReadLine());
for(int i=1; i<=number; i++)
{
factorialNumber = factorialNumber * i;
}
Console.Write($"Factorial number of {number} is {factorialNumber}");
}
}
}
Output:
Please enter a number:6 Factorial number of 6 is 720