P8 To find the factorial of a given number

    class Program
    {
        static void Main(string[] args)
        {
            int n, fact = 1;
            Console.Write("Enter the number : ");
            n = int.Parse(Console.ReadLine());
            for (int i = 1; i <= n; i++)
            {
                fact = fact * i;
            }
            Console.WriteLine("Factorial value of " + n + " is " + fact);
            Console.ReadLine();
        }
    }

Output : 




No comments:

Post a Comment