Just another update

This commit is contained in:
Ingy döt Net 2015-02-20 00:35:01 -05:00
parent a25938f123
commit 00a190b0a6
6591 changed files with 94363 additions and 23227 deletions

View file

@ -1,17 +1,18 @@
public class Binom {
public class Binomial
{
private static long binomial(int n, int k)
{
if (k>n-k)
k=n-k;
static long combinations(int n, int k) {
long coeff = 1;
for (int i = n - k + 1; i <= n; i++) {
coeff *= i;
}
for (int i = 1; i <= k; i++) {
coeff /= i;
}
return coeff;
}
long b=1;
for (int i=1, m=n; i<=k; i++, m--)
b=b*m/i;
return b;
}
public static void main(String[] args){
System.out.println(combinations(5, 3));
public static void main(String[] args)
{
System.out.println(binomial(5, 3));
}
}