Skip to content

Commit efd5c5d

Browse files
Update greatest_common_divisor.py
1 parent f3daa2a commit efd5c5d

File tree

1 file changed

+1
-5
lines changed

1 file changed

+1
-5
lines changed

maths/greatest_common_divisor.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,6 @@ def greatest_common_divisor(a: int, b: int) -> int:
3333
>>> greatest_common_divisor(0, 0)
3434
0
3535
"""
36-
if a == 0 and b == 0:
37-
return 0
3836
return abs(b) if a == 0 else greatest_common_divisor(b % a, a)
3937

4038

@@ -57,9 +55,7 @@ def gcd_by_iterative(x: int, y: int) -> int:
5755
>>> gcd_by_iterative(0, 0)
5856
0
5957
"""
60-
if x == 0 and y == 0:
61-
return 0
62-
while y:
58+
while y: # --> when y=0 then loop will terminate and return x as final GCD.
6359
x, y = y, x % y
6460
return abs(x)
6561

0 commit comments

Comments
 (0)