查找数字列表的最大公约数

5年以前  |  阅读数:440 次  |  编程语言:Python 

此函数计算数字列表中的最大公约数。

from functools import reduce
import math
def gcd(numbers):
    return reduce(math.gcd, numbers)
gcd([24,108,90]) # 6

Copyright© 2013-2020

All Rights Reserved 京ICP备2023019179号-8