Skip to content
This repository was archived by the owner on Sep 7, 2025. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
UPDATED THE GCD FUNCTION AND MADE IT MORE EFFICIENT
  • Loading branch information
DEVIL-NEEL committed Oct 21, 2022
commit e41fd42a4b882190e6b024474bb1411404cd50fe
15 changes: 6 additions & 9 deletions algorithms/math/gcd.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
def gcd(A, B):
if B>A:
A, B = B, A
while B!=0:
temp = B
B = A%B
A = temp
return A
#EUCLIDEAN ALGORITHM FOR GCD CALCULATION
def computeGCD(x,y):
while(y):
x,y= y, x % y
return abs(x)

print(gcd(10,20))
print(computeGCD(10,20))