programming-examples/c-sharp/Mathematics/C# Program to Generate the Factorial of Given Number.cs

32 lines
674 B
C#
Raw Normal View History

2019-11-15 12:59:38 +01:00
/*
* C# Program to Generate the Factorial of Given Number
*/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace factorial
{
class Program
{
static void Main(string[] args)
{
int i, number, fact;
Console.WriteLine("Enter the Number");
number = int.Parse(Console.ReadLine());
fact = number;
for (i = number - 1; i >= 1; i--)
{
fact = fact * i;
}
Console.WriteLine("\nFactorial of Given Number is: "+fact);
Console.ReadLine();
}
}
}
/*
Enter the Number
6
Factorial of Given Number is: 720