Skip to content

Commit 435b29b

Browse files
Update gcd.py
1 parent e3a1344 commit 435b29b

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

gcd.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
a = int(input("Enter number 1 (a): "))
66
b = int(input("Enter number 2 (b): "))
77

8-
i = 1
9-
while i <= a and i <= b:
10-
if a % i == 0 and b % i == 0:
11-
gcd = i
12-
i = i + 1
8+
def calc_GCD(x,y):
9+
if y==0:
10+
return x
11+
return calc_GCD(y,x%y)
12+
gcd=calc_GCD(a,b)
1313

1414
print("\nGCD of {0} and {1} = {2}".format(a, b, gcd))

0 commit comments

Comments
 (0)