Created
September 2, 2016 16:13
-
-
Save shivamMg/630a4bb780c335875a19e0e8df7d4370 to your computer and use it in GitHub Desktop.
nCr
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def comb(n, r): | |
c = 1 | |
if r > n / 2: | |
r = n - r | |
for i in xrange(1, r+1): | |
c *= n - r + i | |
c /= i | |
return c |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment