Skip to content

Commit f1d3088

Browse files
author
Ian Doarn
authored
Merge pull request OmkarPathak#98 from agrdivyam/patch-1
Create GCD.py
2 parents f04331a + 4e41b3f commit f1d3088

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

pygorithm/math/GCD.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
def find_gcd(x, y):
2+
3+
while(y):
4+
x, y = y, x % y
5+
6+
return x
7+
8+
9+
l = [2, 4, 6, 8, 16]
10+
11+
num1 = l[0]
12+
num2 = l[1]
13+
gcd = find_gcd(num1, num2)
14+
15+
for i in range(2, len(l)):
16+
gcd = find_gcd(gcd, l[i])
17+
18+
print(gcd)

0 commit comments

Comments
 (0)