0
Write a python script to calculate nCr using functions..
2 Réponses
+ 5
Samuel is right. In the end, you just need to write
print nCr(x,y)
where x,y can be anything but x>y of course.😜
+ 2
import operator as op
def nCr(n, r):
r = min(r, n-r)
if r == 0:
return 1
numer = reduce(op.mul, xrange(n, n-r, -1))
denom = reduce(op.mul, xrange(1, r+1))
return numer // denom