one-file-projects/binomial.py
2015-04-22 18:33:54 +02:00

13 lines
252 B
Python

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
def E(n,k):
return binomcoeff(2*n+k,n)*binomcoeff(n+k,n)//2
print(E(1,2), E(2,1), E(2,2), E(3,1))