题解 | #求最小公倍数#
求最小公倍数
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) { const [n1,n2]= line.split(" ").map(x=>parseInt(x)) solution(n1,n2,1,1,n1,n2) }); function solution(n1,n2,mul1,mul2,r1,r2){ if(r1 === r2){ console.log(r1) return r1 } if(r1>r2){ return solution(n1,n2,mul1,mul2+1,r1,n2*(mul2+1)) } if(r1 <r2){ return solution(n1,n2,mul1+1,mul2,n1*(mul1+1),r2) } }#递归#