题解 | #求最小公倍数#

求最小公倍数

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

import math

def find_lcm(a: int, b: int) -> int:
    """
    计算两个正整数a和b的最小公倍数(LCM)
    """
    gcd_value = math.gcd(a, b)
    lcm_value = abs(a * b) // gcd_value
    return lcm_value

# 示例
a, b = map(int, input().split())
lcm_result = find_lcm(a, b)
print(lcm_result)

全部评论

相关推荐

点赞 评论 收藏
分享
10-17 13:54
上海大学 运营
雾凇岛:这还说什么了,冲了兄弟们
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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