Python-100-Days/Day01-15/Day04/code/for5.py

20 lines
398 B
Python
Raw Normal View History

2018-03-02 00:09:06 +08:00
"""
输入两个正整数计算最大公约数和最小公倍数
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