题解 | #求最小公倍数# #辗转相除法# #最大公约数#
求最小公倍数
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 input = line.split(' ')
let a = parseInt(input[0]);
let b = parseInt(input[1]);
let g = gcd(a, b);
console.log(a * b / g);
}
}()
function gcd(a, b){
if(a%b === 0) return b;
return gcd(b, a%b);
}
查看14道真题和解析