Skip to content

Commit 7d9ebee

Browse files
chore: rename gcd to greatest_common_divisor (TheAlgorithms#6265)
As described in CONTRIBUTING.md > Expand acronyms because gcd() is hard to understand but greatest_common_divisor() is not. Co-authored-by: Dhruv Manilawala <[email protected]>
1 parent d53fdc2 commit 7d9ebee

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

project_euler/problem_005/sol2.py

+9-9
Original file line numberDiff line numberDiff line change
@@ -16,28 +16,28 @@
1616
"""
1717

1818

19-
def gcd(x: int, y: int) -> int:
19+
def greatest_common_divisor(x: int, y: int) -> int:
2020
"""
21-
Euclidean GCD algorithm (Greatest Common Divisor)
21+
Euclidean Greatest Common Divisor algorithm
2222
23-
>>> gcd(0, 0)
23+
>>> greatest_common_divisor(0, 0)
2424
0
25-
>>> gcd(23, 42)
25+
>>> greatest_common_divisor(23, 42)
2626
1
27-
>>> gcd(15, 33)
27+
>>> greatest_common_divisor(15, 33)
2828
3
29-
>>> gcd(12345, 67890)
29+
>>> greatest_common_divisor(12345, 67890)
3030
15
3131
"""
3232

33-
return x if y == 0 else gcd(y, x % y)
33+
return x if y == 0 else greatest_common_divisor(y, x % y)
3434

3535

3636
def lcm(x: int, y: int) -> int:
3737
"""
3838
Least Common Multiple.
3939
40-
Using the property that lcm(a, b) * gcd(a, b) = a*b
40+
Using the property that lcm(a, b) * greatest_common_divisor(a, b) = a*b
4141
4242
>>> lcm(3, 15)
4343
15
@@ -49,7 +49,7 @@ def lcm(x: int, y: int) -> int:
4949
192
5050
"""
5151

52-
return (x * y) // gcd(x, y)
52+
return (x * y) // greatest_common_divisor(x, y)
5353

5454

5555
def solution(n: int = 20) -> int:

0 commit comments

Comments
 (0)