如果你有一个python中的整数列表,比如L = [4,8,12,24]
,你如何计算它们最大的公分母/除数(在这种情况下为4)?
One way to do it is:
import fractions
def gcd(L):
return reduce(fractions.gcd, L)
print gcd([4,8,12,24])
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.