Skip to content

Instantly share code, notes, and snippets.

@Scinawa
Last active March 24, 2016 06:16
Show Gist options
  • Save Scinawa/1c6f5b5bcbec0a17bf0e to your computer and use it in GitHub Desktop.
Save Scinawa/1c6f5b5bcbec0a17bf0e to your computer and use it in GitHub Desktop.
Functions from N to X, up to a permutation of N
from math import factorial
x=10
n=3
res = math.factorial(x+n-1) / ( math.factorial(n) * math.factorial(x+n-1-n))
>>> len([i for i in itertools.combinations_with_replacement(range(0,x), n)]) == res
True
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment