diff --git a/src/Python/Problems001-050/Problem005.py b/src/Python/Problems001-050/Problem005.py index fc9fe86..9df5c62 100644 --- a/src/Python/Problems001-050/Problem005.py +++ b/src/Python/Problems001-050/Problem005.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python3 +#!/usr/bin/env python """ Created on 23 Apr 2017 @@ -9,7 +9,8 @@ Solution for problem 5 of Project Euler https://projecteuler.net/problem=5 """ -import math +from math import gcd + from utils import timeit # The LCM of two natural numbers x and y is given by: @@ -29,13 +30,13 @@ def compute(): What is the smallest positive number that is evenly divisible by all of the numbers from 1 to 20? """ + ans = 1 for i in range(1, 21): - ans *= i // math.gcd(i, ans) + ans *= i // gcd(i, ans) return ans if __name__ == "__main__": - - print(f"Result for problem 5: {compute()}") + print(f"Result for problem 5 is {compute()}")