Skip to content

Instantly share code, notes, and snippets.

@shieldsd
Created March 30, 2012 14:33
Show Gist options
  • Save shieldsd/2251945 to your computer and use it in GitHub Desktop.
Save shieldsd/2251945 to your computer and use it in GitHub Desktop.
Project Euler #33
def gcd(i, j):
while j:
i, j = j, i % j
return i
n, d = reduce(lambda (n1,d1), (n2, d2): (n1*n2, d1*d2),
((n, d)
for i in range(1, 11)
for d in range(1, i)
for n in range(1, d)
if (n * 10 + i) * d == n * (i * 10 + d)))
print d / gcd(n, d)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment