题解 | #求最小公倍数#

求最小公倍数

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 = parseInt(tokens[0]);
        let b = parseInt(tokens[1]);
        // console.log(); 
        minfather=a*b/maxson(a,b)
        console.log(minfather)
    }
}()

function maxson(a,b){
    if(a>b){
        return maxson(a-b,b)
    }else if(a<b){
        return maxson(b-a,a)
    }else if(a==b){
        return a
    }
}

全部评论

相关推荐

点赞 收藏 评论
分享
牛客网
牛客企业服务