uj5u.com熱心網友回復:
def gcd(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:
gcd = i
return gcd
def lcm(x, y): # 最小公倍數
if x > y:
greater = x
else:
greater = y
while True:
if greater % x == 0 and greater % y == 0:
lcm = greater
break
greater += 1
return lcm
n1 = int(input())
n2 = int(input())
print(gcd(n1, n2), lcm(n1, n2))
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/49856.html
