C# Program - Factorial of a number | Digital Infotainment

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            int i,f, fact=1;
            Console.Write("Enter a number");
            f = int.Parse(Console.ReadLine());
            for(i=1;i<=f;i++)
            fact=fact*i;
            Console.Write("The factorial of the number is:"+fact);
            Console.ReadKey();
        }
    }
}

/*Do leave a comment if you find this useful*/

No comments:

Post a comment