返回主页

最小公倍数

常常和最大公约数配合使用

工具函数发布于 2026/08/19#最小公倍数#数学
C++3 行87 Bytes
下载文件
int lcm(int a, int b) {
    return a / gcd(a, b) * b;  // 先除后乘,防止溢出
}