18 lines
420 B
Python
18 lines
420 B
Python
|
"""
|
||
|
输入两个正整数计算最大公约数和最小公倍数
|
||
|
|
||
|
Version: 0.1
|
||
|
Author: 骆昊
|
||
|
Date: 2018-03-01
|
||
|
"""
|
||
|
|
||
|
x = int(input('x = '))
|
||
|
y = int(input('y = '))
|
||
|
if x > y:
|
||
|
(x, y) = (y, x)
|
||
|
for factor in range(x, 0, -1):
|
||
|
if x % factor == 0 and y % factor == 0:
|
||
|
print('%d和%d的最大公约数是%d' % (x, y, factor))
|
||
|
print('%d和%d的最小公倍数是%d' % (x, y, x * y // factor))
|
||
|
break
|