From 14a928d098eb4863ba033f4998e6272268be6d69 Mon Sep 17 00:00:00 2001 From: ksharma20 Date: Sun, 24 Jul 2022 11:12:34 +0530 Subject: [PATCH 1/2] renamed gcd() to greatest_comman_divisor() fixed naming convension as described in Contribution.md > Expand acronyms because gcd() is hard to understand but greatest_common_divisor() is not. --- project_euler/problem_005/sol2.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/project_euler/problem_005/sol2.py b/project_euler/problem_005/sol2.py index c88044487d20..6564e2064f3b 100644 --- a/project_euler/problem_005/sol2.py +++ b/project_euler/problem_005/sol2.py @@ -16,28 +16,28 @@ """ -def gcd(x: int, y: int) -> int: +def greatest_common_divisor(x: int, y: int) -> int: """ - Euclidean GCD algorithm (Greatest Common Divisor) + Euclidean Greatest Comman 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: From 60355af4b99118cab9823e054327a67829ae0046 Mon Sep 17 00:00:00 2001 From: Dhruv Manilawala Date: Sun, 24 Jul 2022 20:53:28 +0530 Subject: [PATCH 2/2] fix: typo --- project_euler/problem_005/sol2.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project_euler/problem_005/sol2.py b/project_euler/problem_005/sol2.py index 6564e2064f3b..1b3e5e130f03 100644 --- a/project_euler/problem_005/sol2.py +++ b/project_euler/problem_005/sol2.py @@ -18,7 +18,7 @@ def greatest_common_divisor(x: int, y: int) -> int: """ - Euclidean Greatest Comman Divisor algorithm + Euclidean Greatest Common Divisor algorithm >>> greatest_common_divisor(0, 0) 0