Skip to content

Commit e068b77

Browse files
committed
Improve docstring clarity for gcd function
1 parent 3c88735 commit e068b77

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

maths/gcd.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
def gcd(a: int, b: int) -> int:
2+
"""
3+
Compute the Greatest Common Divisor (GCD) of two integers using
4+
the Euclidean algorithm.
5+
6+
The GCD is the largest positive integer that divides both numbers
7+
without leaving a remainder.
8+
9+
>>> gcd(48, 18)
10+
6
11+
>>> gcd(7, 5)
12+
1
13+
>>> gcd(0, 10)
14+
10
15+
>>> gcd(10, 0)
16+
10
17+
18+
:param a: first integer
19+
:param b: second integer
20+
:return: greatest common divisor of a and b
21+
"""

0 commit comments

Comments
 (0)