Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
25 lines (16 sloc) 412 Bytes
from functools import reduce
def spread(arg):
ret = []
for i in arg:
if isinstance(i, list):
ret.extend(i)
else:
ret.append(i)
return ret
def gcd(*args):
numbers = []
numbers.extend(spread(list(args)))
def _gcd(x, y):
return x if not y else gcd(y, x % y)
return reduce(lambda x, y: _gcd(x, y), numbers)
print(gcd(8, 2, [2, 4]))
You can’t perform that action at this time.