Skip to content

Instantly share code, notes, and snippets.

@shivamMg
Created September 2, 2016 16:13
Show Gist options
  • Save shivamMg/630a4bb780c335875a19e0e8df7d4370 to your computer and use it in GitHub Desktop.
Save shivamMg/630a4bb780c335875a19e0e8df7d4370 to your computer and use it in GitHub Desktop.
nCr
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