题解 | #求最小公倍数#
求最小公倍数
https://www.nowcoder.com/practice/22948c2cad484e0291350abad86136c3
const rl = require("readline").createInterface({ input: process.stdin });
var iter = rl[Symbol.asyncIterator]();
const readline = async () => (await iter.next()).value;
void (async function () {
// Write your code here
while ((line = await readline())) {
let tokens = line.split(" ");
let a = tokens[0];
let b = tokens[1];
let mul = a*b;
while (a % b !== 0) { // 辗转相除法求最大公约数
let c = a % b;
a = b;
b = c;
}
// b为最大公约数
console.log(mul/b); // 最小公倍数=两数的乘积/最大公约数
}
})();
