#!/usr/bin/env python from common import factorial SIDE = 20 # Central binomial coefficients (permutations of 0,1) # ((2n)! choose n!^2 ) v = factorial(2 * SIDE) // (factorial(SIDE)**2) print(v)
def signedPerm(n): print (factorial(n) * 2**n) plist = range(1,n+1) _perm([], plist, n)
from common import factorial n = 100 sum = 0 fact_n = factorial(n) for digit in str(fact_n): sum += int(digit) print sum
from common import factorial target = 1000000 first_digit = 3 perms_first_digit = target - factorial(9) * (first_digit - 1)
def perm(n): print factorial(n) plist = range(1,n+1) _perm([], plist)
#!/usr/bin/env python from common import factorial, to_digits from itertools import count fs = list(factorial(n) for n in range(0, 10)) S = 0 for i in count(10): if i > 100000: break s = sum(fs[d] for d in to_digits(i)) if s == i: S += i print(S)
def get_S(p): S = 0 for k in xrange(1, 5+1): S += factorial(p-k) return S % p
from itertools import permutations from common import factorial SIZE = 20 num_routes = factorial(2 * SIZE) / (factorial(SIZE)**2) print num_routes