Created
January 12, 2017 02:02
-
-
Save nattybear/657fcf3a2221c3802856f673ecdced25 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
# python 2.7.9 | |
# get factorial | |
def fact(n): | |
ret = 1 | |
for i in range(1, n+1): | |
ret = ret * i | |
return ret | |
# get combination | |
def comb(n, k): | |
return fact(n) / fact(k) / fact(n-k) | |
# print result using iteration | |
for i in range(6): | |
for j in range(i+1): | |
print '%dC%d = %d' % (i, j, comb(i, j)), | |
print '' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment