diff --git a/project_euler/problem_005/sol2.py b/project_euler/problem_005/sol2.py index c88044487..1b3e5e130 100644 --- a/project_euler/problem_005/sol2.py +++ b/project_euler/problem_005/sol2.py @@ -16,28 +16,28 @@ References: """ -def gcd(x: int, y: int) -> int: +def greatest_common_divisor(x: int, y: int) -> int: """ - Euclidean GCD algorithm (Greatest Common Divisor) + Euclidean Greatest Common Divisor algorithm - >>> gcd(0, 0) + >>> greatest_common_divisor(0, 0) 0 - >>> gcd(23, 42) + >>> greatest_common_divisor(23, 42) 1 - >>> gcd(15, 33) + >>> greatest_common_divisor(15, 33) 3 - >>> gcd(12345, 67890) + >>> greatest_common_divisor(12345, 67890) 15 """ - return x if y == 0 else gcd(y, x % y) + return x if y == 0 else greatest_common_divisor(y, x % y) def lcm(x: int, y: int) -> int: """ Least Common Multiple. - Using the property that lcm(a, b) * gcd(a, b) = a*b + Using the property that lcm(a, b) * greatest_common_divisor(a, b) = a*b >>> lcm(3, 15) 15 @@ -49,7 +49,7 @@ def lcm(x: int, y: int) -> int: 192 """ - return (x * y) // gcd(x, y) + return (x * y) // greatest_common_divisor(x, y) def solution(n: int = 20) -> int: