Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
|
|
@ -0,0 +1,37 @@
|
|||
using System;
|
||||
|
||||
namespace BinomialCoefficients
|
||||
{
|
||||
class Program
|
||||
{
|
||||
static void Main(string[] args)
|
||||
{
|
||||
ulong n = 1000000, k = 3;
|
||||
ulong result = biCoefficient(n, k);
|
||||
Console.WriteLine("The Binomial Coefficient of {0}, and {1}, is equal to: {2}", n, k, result);
|
||||
Console.ReadLine();
|
||||
}
|
||||
|
||||
static int fact(int n)
|
||||
{
|
||||
if (n == 0) return 1;
|
||||
else return n * fact(n - 1);
|
||||
}
|
||||
|
||||
static ulong biCoefficient(ulong n, ulong k)
|
||||
{
|
||||
if (k > n - k)
|
||||
{
|
||||
k = n - k;
|
||||
}
|
||||
|
||||
ulong c = 1;
|
||||
for (uint i = 0; i < k; i++)
|
||||
{
|
||||
c = c * (n - i);
|
||||
c = c / (i + 1);
|
||||
}
|
||||
return c;
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue