小编red*_*use的帖子

Python GCD列表

我想为数字列表计算gcd。但是我不知道我的代码有什么问题。

A = [12, 24, 27, 30, 36]


def Greatest_Common_Divisor(A):
    for c in A:
        while int(c) > 0:
            if int(c) > 12:
                c = int(c) % 12
            else:
                return 12 % int(c)
    print Greatest_Common_Divisor(A)
Run Code Online (Sandbox Code Playgroud)

python greatest-common-divisor

4
推荐指数
6
解决办法
1万
查看次数

标签 统计

greatest-common-divisor ×1

python ×1