c# program to find factorial of a number - C# Program

C# program to find factorial of a number

In mathematics,the factorial of a non-negative integer n, denoted by n!, is the product of all positive integers less than or equal to n. For example, 5 ! = 5 × 4 × 3 × 2 × 1 = 120

using System;

namespace FactorialNumber
{
    class Program
    {
        static void Main(string[] args)
        {
            int num;
            int fn = 1;
            Console.Write("Enter the Number :");
            num = Convert.ToInt32(Console.ReadLine());
            int n = num;
            while(n>=1)
            {
                fn = fn * n;
                n--;
            }
            Console.WriteLine("Factorial Number of {0} is {1}", num, fn);

                
            Console.ReadKey();
        }
    }
}

Output - c# program to find factorial of a number

Enter the Number :5
Factorial Number of 5 is 120

c# program to find factorial of a number