16 lines
372 B
Text
16 lines
372 B
Text
// Binomial Coeffizient, n!/(k!*(n-k)!).
|
|
def fac(x):
|
|
f = 1
|
|
counter = 0
|
|
for i in 1..100 do
|
|
f = if counter == x then f else f * i fi
|
|
counter = if counter == x then counter else counter + 1 fi
|
|
endfor
|
|
return f
|
|
def main(n, k):
|
|
top = fac(n)
|
|
bot1 = fac(k)
|
|
sub = n - k
|
|
bot2 = fac(sub)
|
|
bot = bot1 * bot2
|
|
return top / bot
|