题解 | #求最小公倍数#

求最小公倍数

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 () {
    let input = await readline();
    let [m,n] = input.split(' ').map((e)=>parseInt(e));
    let multiplyNum = m*n;
    let res = -1;
    if( m % n == 0){
        console.log(m);
        return
    }
    else if(n % m == 0){
        console.log(n)
        return 
    }
    for(let i =1;i<= multiplyNum;i++){
        if(i % m == 0 && i % n ==0){
            res = i;
            break;
        }
    }
    console.log(res)
}()

全部评论

相关推荐

程序员小屁:帮你了查看图片
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务