Last active
August 29, 2015 13:56
-
-
Save waylon531/9027315 to your computer and use it in GitHub Desktop.
Greatest common divisor using the Euclidian Algorithm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys,math | |
a = float(sys.argv[1]) | |
b = float(sys.argv[2]) | |
remainder = 1.0 | |
if a<b: | |
a=b | |
b=float(sys.argv[1]) | |
c = a/b | |
while(round(remainder,2)!=0): | |
q=math.floor(c+.000001) | |
remainder=c-q | |
a=b | |
b=remainder*b | |
if b!=0: | |
c=a/b | |
#print c,a,b,q,remainder | |
print int(round(a)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment