题解 | #求最小公倍数#
求最小公倍数
https://www.nowcoder.com/practice/22948c2cad484e0291350abad86136c3
两个数的最小公倍数乘以两数的最大公约数等于两数乘积。
求最大公约数有非常优秀的辗转相除法。
const readline = require('readline'); const rl = readline.createInterface({ input: process.stdin, output: process.stdout }); rl.on('line', function (line) { let [a,b] = line.split(' '); function gcd(a, b) { if (a % b == 0) return b; return gcd(b, a % b); } console.log(a * b / gcd(a,b)); });