1
0
Fork 0
mirror of synced 2025-09-23 12:18:44 +00:00
ZoKrates/examples/n_choose_k.code
2017-11-08 17:10:19 +01:00

12 lines
295 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):
return fac(n)/(fac(k)*fac(n-k))