Skip to content

Instantly share code, notes, and snippets.

@amoshyc
Created February 7, 2015 13:40
Show Gist options
  • Save amoshyc/741f915c66782504d896 to your computer and use it in GitHub Desktop.
Save amoshyc/741f915c66782504d896 to your computer and use it in GitHub Desktop.
Project Euler #5
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

def lcm(a, b):
    return max(a, b) // gcd(a, b) * min(a, b)

ans = 1
for i in range(2, 20+1):
    ans = lcm(ans, i)

print(ans)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment