Project Euler Problem 53
I wrote a bunch of these but never posted them up, so I'm just uploading them in bulk now. Not much to say about them at this point.
- #!/usr/bin/python
- import math
- memo = {}
- def c(n, r):
- if not n in memo:
- memo[n] = math.factorial(n)
- if not r in memo:
- memo[r] = math.factorial(r)
- if not n-r in memo:
- memo[n-r] = math.factorial(n-r)
- n_r = memo[n-r]
- n = memo[n]
- r = memo[r]
- return n/(r*(n_r))
- count = 0
- for n in range(23, 101):
- for r in range(1, n):
- if c(n, r) > 1000000:
- count+=1
- print count