题解 | #求最小公倍数#
求最小公倍数
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
function getGcd(m, n){ //得到m, n最大公约数
let max = Math.max(m, n);
let min = Math.min(m, n);
if(max % min === 0) return min;
else return getGcd(max % min, min);
}
while(line = await readline()){
let tokens = line.split(' ');
let a = parseInt(tokens[0]);
let b = parseInt(tokens[1]);
console.log(a * b /getGcd(a, b));
}
}()