题解 | #求最小公倍数#
求最小公倍数
https://www.nowcoder.com/practice/22948c2cad484e0291350abad86136c3
def gbs(A,B): """求取A和B的公倍数""" b = max(A, B) i = 0 result = b while True: if b % A == 0 and b % B == 0: break i += 1 b = result * i return b while True: try: list_input = input().split() result = gbs(int(list_input[0]), int(list_input[1])) print(result) except: break
求两个数的公倍数,首先找个两个数中的最大值,看看是否整除,然后逐个寻找,找到就停止输出最终结果