Skip to content

Instantly share code, notes, and snippets.

@clementi
Created February 12, 2011 02:25
Show Gist options
  • Save clementi/823420 to your computer and use it in GitHub Desktop.
Save clementi/823420 to your computer and use it in GitHub Desktop.
Project Euler Problem #53 Solution
import operator
def factorial(n):
return 1 if n == 0 else reduce(operator.mul, range(1, n + 1))
def combo(n, r):
return factorial(n) / (factorial(r) * factorial(n - r))
count = 0
for (n, r) in [(n, r) for n in range(1, 101) for r in range(1, n)]:
if combo(n, r) > 1000000:
count += 1
print count
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment