We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 3c88735 commit e068b77Copy full SHA for e068b77
1 file changed
maths/gcd.py
@@ -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
17
18
+ :param a: first integer
19
+ :param b: second integer
20
+ :return: greatest common divisor of a and b
21
0 commit comments