题解 | #求最小公倍数#

求最小公倍数

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

相关推荐

程序员花海:实习和校招简历正确格式应该是教育背景+实习+项目经历+个人评价 其中项目经历注意要体现业务 实习经历里面的业务更是要自圆其说 简历模板尽可能保持干净整洁 不要太花哨的
投了多少份简历才上岸
点赞 评论 收藏
分享
评论
5
3
分享

创作者周榜

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