From 6912146be78d13f5fe99296d2410272b9b9cd1b2 Mon Sep 17 00:00:00 2001 From: daviddoji Date: Wed, 21 Sep 2022 20:44:58 +0200 Subject: [PATCH] Adopted new convention from template --- src/Python/Problems001-050/Problem005.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) 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()}")