Skip to content

Commit e3d4d2b

Browse files
percy07cclauss
authored andcommitted
Update greatest_common_divisor.py (TheAlgorithms#1513)
Add Doctests.
1 parent e463c0b commit e3d4d2b

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

maths/greatest_common_divisor.py

+10
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,16 @@ def greatest_common_divisor(a, b):
1010
Calculate Greatest Common Divisor (GCD).
1111
>>> greatest_common_divisor(24, 40)
1212
8
13+
>>> greatest_common_divisor(1, 1)
14+
1
15+
>>> greatest_common_divisor(1, 800)
16+
1
17+
>>> greatest_common_divisor(11, 37)
18+
1
19+
>>> greatest_common_divisor(3, 5)
20+
1
21+
>>> greatest_common_divisor(16, 4)
22+
4
1323
"""
1424
return b if a == 0 else greatest_common_divisor(b % a, a)
1525

0 commit comments

Comments
 (0)