one-file-projects/binomial.py

14 lines
252 B
Python
Raw Normal View History

2015-04-22 18:33:54 +02:00
def binomcoeff(n,k):
nom = 1
denum = 1
for i in range(n-k):
nom *= (n-i)
denum *= (i+1)
v = nom//denum
return v
2014-11-04 13:02:25 +01:00
2015-04-22 18:33:54 +02:00
def E(n,k):
return binomcoeff(2*n+k,n)*binomcoeff(n+k,n)//2
2014-11-04 13:02:25 +01:00
2015-04-22 18:33:54 +02:00
print(E(1,2), E(2,1), E(2,2), E(3,1))