326 B
326 B
gcd
Calculates the greatest common divisor of a list of numbers.
Uses the reduce function from the inbuilt module functools. Also uses the math.gcd function over a list.
from functools import reduce
import math
def gcd(numbers):
return reduce(math.gcd, numbers)
gcd([8,36,28]) # 4