The factorial of a positive integer n, denoted by n!, is the product of all positive integers less than or equal to n. (wiki)
For example,
using System; namespace Program { class Program { static void Main(string[] args) { int i, num, fact; Console.WriteLine("Enter number: "); num = Convert.ToInt16(Console.ReadLine()); fact = num; for (i = num - 1; i >= 1; i--) { fact = fact * i; } Console.WriteLine("\nFactorial of given number is: " + fact); Console.ReadLine(); } } }
Output