Skip to content

Instantly share code, notes, and snippets.

@Deathnerd
Forked from anonymous/Test.py
Created February 27, 2016 17:42
Show Gist options
  • Save Deathnerd/2870bd737f8279891866 to your computer and use it in GitHub Desktop.
Save Deathnerd/2870bd737f8279891866 to your computer and use it in GitHub Desktop.
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