#!/usr/bin/env python

‘’’
求两个整数的最大公约数和最小公倍数,最大公约数和最小公倍数的乘积是两个整数的乘积
‘’’
#辗转相除法

a=int(input(‘please enter 1st num:’))
b=int(input(‘please enter 2nd num:’))
s=a*b
while a%b !=0:
a,b=b,(a%b)
else:
print(b,‘is the maximum common divisor’)
print(s//b,‘is the least common multiple’)

Logo

CSDN联合极客时间,共同打造面向开发者的精品内容学习社区,助力成长!

更多推荐