题解 | #Redraiment的走法#

求最小公倍数

http://www.nowcoder.com/practice/22948c2cad484e0291350abad86136c3

先求最大公约数,再求最大公倍数 公倍数 (x*y)/最大公约数

let line


function get_base_min(x,y){
    if(y == 0 ){
        return x
    }
    let z = x % y;
    return get_base_min(y,z)
}

function get_base_max(x,y){
    return (x * y) / get_base_min(x,y)
}
while(line = readline()){
      let arr = line.split(' ').map(i=>parseInt(i))
      let res = get_base_max(arr[0],arr[1]);
        console.log(res);
        arr = []
}
全部评论

相关推荐

不愿透露姓名的神秘牛友
今天 13:47
点赞 评论 收藏
分享
评论
2
收藏
分享

创作者周榜

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