Skip to content

Instantly share code, notes, and snippets.

@vdonchev
Created August 12, 2015 05:05
Show Gist options
  • Save vdonchev/4e3a9e52a0533cd15ece to your computer and use it in GitHub Desktop.
Save vdonchev/4e3a9e52a0533cd15ece to your computer and use it in GitHub Desktop.
using System;
using System.Numerics;
namespace ConsoleApplication18
{
class Program
{
static void Main()
{
Console.WriteLine("Enter N=");
BigInteger n = BigInteger.Parse(Console.ReadLine());
Console.WriteLine("Enter K=");
BigInteger k = BigInteger.Parse(Console.ReadLine());
BigInteger sumK = 1;
BigInteger sumN = 1;
BigInteger sumM = 1;
if (1 < k && k < n && n < 100)
{
for (int i = 1; i <= n; i++)
{
sumN *= i;
}
for (int j = 1; j <= k; j++)
{
sumK *= j;
}
for (int m = 1; m <= (n - k); m++)
{
sumM *= m;
}
BigInteger sumF = sumN / (sumK * sumM);
Console.WriteLine("{0}", sumF);
}
else
{
Console.WriteLine("Wrong input");
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment