C# Generate the Factorial of Given Number

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,

{\displaystyle 5!=5\times 4\times 3\times 2\times 1=120\,.} 

 

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