题解 | #求最小公倍数#

求最小公倍数

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

import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        while(sc.hasNextInt()){
            int a = sc.nextInt();
            int b = sc.nextInt();
            for(int i = Math.min(a,b); i > 0; i--){
                if(a%i == 0 && b%i == 0){
                    System.out.println(a*b/i);
                    break;
                }
            }
        }
    }
}
全部评论
厉害
点赞 回复 分享
发布于 2024-07-28 20:23 广东
最大公因子?
点赞 回复 分享
发布于 2023-03-03 19:56 广西
大哥,牛牛牛!!!
点赞 回复 分享
发布于 2022-08-30 11:05 陕西
牛啊
点赞 回复 分享
发布于 2022-06-17 14:21
找最大公因数
点赞 回复 分享
发布于 2022-04-14 00:45
大哥厉害
点赞 回复 分享
发布于 2021-10-20 22:27

相关推荐

评论
28
2
分享

创作者周榜

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