Created
March 26, 2014 15:35
-
-
Save klen/9786162 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" Project Euler problem #5. """ | |
from fractions import gcd | |
def problem(): | |
""" Solve the problem. | |
2520 is the smallest number that can be divided by each of the numbers | |
from 1 to 10 without any remainder. | |
What is the smallest positive number that is evenly divisible by all of | |
the numbers from 1 to 20? | |
Answer: 232792560 | |
""" | |
def _lowest_common_multi(a, b): | |
return a * b // gcd(a, b) | |
return reduce(_lowest_common_multi, range(1, 21)) | |
if __name__ == '__main__': | |
print problem() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment