def f(a, b):
if a > b:
smaller = b
else:
smaller = a
for i in range(2, smaller+1):
if a % i == 0 and b % i == 0:
return i
print("%d是最大公约数", f(35, 14))
def f(a, b):
if a > b:
smaller = b
else:
smaller = a
for i in range(2, smaller+1):
if a % i == 0 and b % i == 0:
return i
print("%d是最大公约数", f(35, 14))
本文标题:Python最大公约数
本文链接:https://www.haomeiwen.com/subject/tdcybctx.html
网友评论