Created
February 27, 2016 17:36
-
-
Save anonymous/d0170383e75d42316d36 to your computer and use it in GitHub Desktop.
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
def factorial(n): | |
if (n == 0): | |
return 1 | |
elif (n == 1): | |
return n | |
else: | |
return n * factorial(n-1) | |
def nCk(n,k): | |
return factorial(n)/(factorial(k)*factorial(n-k)) | |
def noCouples(n): | |
total = 0 | |
for k in range(0,n+1): | |
total += nCk(n,k) * 2**k * factorial(2*n-k) * (-1)**(k) | |
return total | |
print noCouples(4) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment