Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
classic, without recurs solution in Clear category for The Greatest Common Divisor by rybld2
def gcd(a, b):
if a < b: a, b = b, a
while b > 0:
a, b = b, a % b
return a
def greatest_common_divisor(*args):
"""
Find the greatest common divisor
"""
p = gcd(args[0], args[1])
for x in args[2:]:
p = greatest_common_divisor(p, x)
if p == 1: break
return p
June 4, 2021