1. 程式人生 > >求最小公倍數

求最小公倍數

NPU gcd rgs scanner next exti stat max return

public class Gcd {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int x = input.nextInt();
        int y = input.nextInt();
        int gcd = Gcd.gcd(x, y);
            System.out.println(gcd+" "+x*y/gcd);
    }

    public static int gcd(int a, int
b) { int max, min; max = (a > b) ? a : b; min = (a < b) ? a : b; if (max % min != 0) { return gcd(min, max % min); } else return min; } }

求最小公倍數