|
发表于 2021-12-31 14:02:24
|
显示全部楼层
def gys (x, y):
for i in range(min(x, y),0,-1):
if (x % i == 0) and (y % i == 0):
gys = i
break
return gys
def gbs (x, y):
for j in range(max(x, y), x*y+1):
if (j % x == 0) and (j % y == 0):
gbs = j
break
return gbs
a = int(input("请输入第一个整数: "))
b = int(input("请输入第二个整数: "))
print( a,"和", b,"的最大公约数为",gys(a, b))
print( a,"和", b,"的最小公倍数为", gbs(a, b)) |
|