Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Greatest_common_divisor solution in Uncategorized category for The Greatest Common Divisor by Elena_Korljukova
from functools import reduce
from math import gcd
def greatest_common_divisor(*args):
return reduce(gcd, args)
if __name__ == '__main__':
#These "asserts" using only for self-checking and not necessary for auto-testing
print(greatest_common_divisor(12, 4, 8))
print(greatest_common_divisor(32,256,2048,16384,131072,1048576,8388608,67108864,536870912,4294967296))
assert greatest_common_divisor(6, 4) == 2, "Simple"
assert greatest_common_divisor(2, 4, 8) == 2, "Three arguments"
assert greatest_common_divisor(2, 3, 5, 7, 11) == 1, "Prime numbers"
assert greatest_common_divisor(3, 9, 3, 9) == 3, "Repeating arguments"
May 20, 2020