CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
jackfrued

CoCalc provides the best real-time collaborative environment for Jupyter Notebooks, LaTeX documents, and SageMath, scalable from individual users to large groups and classes!

GitHub Repository: jackfrued/Python-100-Days
Path: blob/master/Day01-15/code/Day04/for5.py
Views: 729
1
"""
2
输入两个正整数计算最大公约数和最小公倍数
3
4
Version: 0.1
5
Author: 骆昊
6
Date: 2018-03-01
7
"""
8
9
x = int(input('x = '))
10
y = int(input('y = '))
11
if x > y:
12
(x, y) = (y, x)
13
for factor in range(x, 0, -1):
14
if x % factor == 0 and y % factor == 0:
15
print('%d和%d的最大公约数是%d' % (x, y, factor))
16
print('%d和%d的最小公倍数是%d' % (x, y, x * y // factor))
17
break
18
19