运行结果:
代码:
def gys(a,b):
t = a
if t > b:
t = b
for x in range(t,0,-1):
if a%x==0 and b%x==0:
return x
return 1
def gbs(a,b):
return a*b/gys(a,b)
print('输入2个整数m,n:')
m,n=map(int,input().split(','))
x=gys(m,n)
y=gbs(m,n)
print('最大公约数:%d'%x)
print('最小公倍数:%d'%y)
from math import gcd, lcm
m, n = map(int, input('输入2个整数m,n:\n').split(','))
print('最大公约数:%d' % gcd(m, n))
print('最小公倍数:%d' % lcm(m, n))