We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 9fe4a37 commit e3c7942Copy full SHA for e3c7942
1 file changed
recipes/Python/Combination without using factorials/combo.py
@@ -7,3 +7,10 @@ def ncr(n, r):
7
num = reduce(op.mul, xrange(n, n-1, -1))
8
denom = reduce(op.mul, xrange(1, r+1))
9
return num // denom
10
+
11
+def ncr3(n, r):
12
+ r = min(r, n-r)
13
+ if x == 0: return 1
14
+ num = reduce(op.mul, range(n, n-1, -1))
15
+ denom = reduce(op.mul, range(1, r+1))
16
+ return num // denom
0 commit comments