C# program to calculates factorial
- C# program to calculates N!/K! for given N and K (1<K<N)
static void Main()
{
Console.WriteLine("Enter number: ");
int n = int.Parse(Console.ReadLine());
int k = int.Parse(Console.ReadLine());
Int64 Nfac = 1;
Int64 Kfac = 1;
Int64 result;
for (int i = 1; i <= n; i++)
{
Nfac = Nfac * i;
}
for (int i = 1; i <= k; i++)
{
Kfac = Kfac * i;
}
result = Nfac / Kfac;
Console.WriteLine(result);
Console.ReadLine();
}
No comments