为什么不退货? 当a或b为0时,必须返回max(a,b)
def gcd(a, b): if a == 0 or b == 0: return max(a, b) else: if a > b: gcd(a-b, b) else: gcd(b-a, a)
印刷品(gcd(1000400))
当你递归调用 gcd
gcd
def gcd(a, b): if a == 0 or b == 0: return max(a, b) else: if a > b: return gcd(a - b, b) else: return gcd(b - a, a)