Skip to content

Instantly share code, notes, and snippets.

@ikbear
Created March 10, 2011 12:16
Show Gist options
  • Save ikbear/864012 to your computer and use it in GitHub Desktop.
Save ikbear/864012 to your computer and use it in GitHub Desktop.
Computing Combinations with Python
import operator
def c(n, k):
return (reduce(operator.mul, range(n-k+1, n+1)) /
reduce(operator.mul, range(1, k+1)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment