题解 | #求最小公倍数#

求最小公倍数

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

import java.util.Scanner;

public class Main {

public static void main(String[] args) {
    //求最小公倍数
    Scanner scanner = new Scanner(System.in);
    int a = scanner.nextInt();
    int b = scanner.nextInt();
    //ax=by
    for (int y = 1; y <= a; y++) {
        double x = b * y * 1.0 / a;
        while (String.valueOf(x).endsWith(".0")) {
            System.out.println(b * y);              
            return;
        }
    }
}

}

全部评论

相关推荐

求offer的大角牛:不吃香菜
点赞 评论 收藏
分享
这是什么操作什么意思,这公司我服了...
斯派克spark:意思是有比你更便宜的牛马了
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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