题解 | #求最小公倍数#

求最小公倍数

http://www.nowcoder.com/practice/feb002886427421cb1ad3690f03c4242

import java.util.*;
public class Main {
    public static void main(String[]args){
        Scanner console = new Scanner(System.in);
        int m = console.nextInt();
        int n = console.nextInt();
        System.out.println(getCM(m,n));
    }
    public static int getCM(int m,int n) {
        int big=(Math.max(m, n));
        int small=(Math.min(m,n));
        int count=0;
        for(int i=small;i<=big*small;i++)
        {
            if(i%small==0&&i%big==0)
            {
                count=i;
                break;
            }
        }
        return count;
    }
}
全部评论
加油哦
点赞 回复 分享
发布于 2023-06-03 17:04 山东
加油
点赞 回复 分享
发布于 2022-04-23 14:40

相关推荐

03-01 21:45
中北大学 Python
孤蓝长空:请你说一下为什么你用websocket而不是http,请你说一下什么是rpc,为什么用rpc,你的rpc的传输协议是JSON,xml还是什么 请你描述一下你的鉴权流程(完整的) 我问的是第二个项目,随便问的哈哈哈
开工第一帖
点赞 评论 收藏
分享
点赞 评论 收藏
分享
评论
6
3
分享

创作者周榜

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