Last active
March 24, 2016 06:16
-
-
Save Scinawa/1c6f5b5bcbec0a17bf0e to your computer and use it in GitHub Desktop.
Functions from N to X, up to a permutation of N
This file contains 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
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