题解 | #求最小公倍数#

求最小公倍数

https://www.nowcoder.com/practice/22948c2cad484e0291350abad86136c3

'''
  2   12 14
       6  7    2*6*7=84

  4   12 16
       3  4    4*3*4=48
  2   12 16 
  2    6  8
       3  4
'''
'''
# 遍历:数字越大,越耗时,超时
num=input().split()
a=int(num[0])
b=int(num[1])
for i in range(1,a*b+1):
    if i%a==0 and i%b==0:
        print(i)
        break
'''
# 按照数学求最小公倍数的过程求解,运行时间较短
num=list(map(int,input().split()))
a=num[0]
b=num[1]
#print(num,a,b)
comul=1
for i in range(2,min(num)+1):
    while a%i==0 and b%i==0:
        comul *= i
        a=a/i
        b=b/i
comul=int(comul*a*b)
print(comul)






全部评论

相关推荐

07-09 19:25
门头沟学院 Java
这是要把每一个投校招的都开盒吗?
26届之耻将大局逆转:裁人的时候一次性追回餐费
点赞 评论 收藏
分享
06-14 19:09
门头沟学院 Java
darius_:给制造业搞的,什么物料管理生产管理,设备管理点检,最最关键的就是一堆报表看板。个人觉得没啥技术含量都是些基本的crud,但是业务很繁琐那种
点赞 评论 收藏
分享
07-09 15:55
门头沟学院 Java
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务