1012 最小公倍数LCM

1012 最小公倍数LCM

基准时间限制:秒 空间限制:131072 KB 

输入2个正整数AB,求AB的最小公倍数。

Input

2个数A,B,中间用空格隔开。(1<= A,B <= 10^9)

Output

输出AB的最小公倍数。

Input示例

30 105

Output示例

210

import java.util.Scanner;
public class Main {
    static long gcd(long a,long b){
        return a%b==0? b:gcd(b,a%b);
    }
    static long LCM(long a,long b){
        return a*b/gcd(a,b);
    }

    public static void main(String[] args) {
        // TODO Auto-generated method stub
        Scanner sc=new Scanner(System.in);
        while(sc.hasNext()){
            long a=sc.nextLong();
            long b=sc.nextLong();
            System.out.println(LCM(a,b));
            
        }
        sc.close();


    }

}
原文地址:https://www.cnblogs.com/watchfree/p/5348671.html