Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Uncategorized category for The Greatest Common Divisor by TovarischZhukov
def gcd(a, b):
while a != b:
if a > b:
a = a % b
if a == 0: return b
else:
b = b % a
if b == 0: return a
return a
def greatest_common_divisor(*args):
tmp=[]
v = list(args)[:]
for a in args:
v.remove(a)
for b in v:
tmp.append(gcd(a, b))
retval = tmp[0]
for elem in tmp[1:]:
retval = gcd(retval, elem)
return retval
Dec. 16, 2015