Skip to content

Commit e41fd42

Browse files
author
DEVIL-NEEL
committed
UPDATED THE GCD FUNCTION AND MADE IT MORE EFFICIENT
1 parent 7f12f2c commit e41fd42

1 file changed

Lines changed: 6 additions & 9 deletions

File tree

algorithms/math/gcd.py

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
1-
def gcd(A, B):
2-
if B>A:
3-
A, B = B, A
4-
while B!=0:
5-
temp = B
6-
B = A%B
7-
A = temp
8-
return A
1+
#EUCLIDEAN ALGORITHM FOR GCD CALCULATION
2+
def computeGCD(x,y):
3+
while(y):
4+
x,y= y, x % y
5+
return abs(x)
96

10-
print(gcd(10,20))
7+
print(computeGCD(10,20))

0 commit comments

Comments
 (0)