实现代码:
def myue(x, y):
if x > y:
smaller = y
else:
smaller = x
for i in range(1, smaller + 1):
if ((x % i == 0) and (y % i == 0)):
myue = i
return myue
num1 = int(input("输入第一个数字: "))
num2 = int(input("输入第二个数字: "))
print(num1,"和",num2, "的最大公约数为", myue(num1, num2))
print(num1,"和",num2,"的最小公倍数为",num1*num2/myue(num1,num2))