View Code of Problem 59


import java.util.Scanner;


public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNext()) {
            long a = scanner.nextLong();
            long b = scanner.nextLong();
            long m=min(a,b);
            long max=(a*b)/m;
            System.out.printf("%d %d",max,m);
        }

    }


    public static long min(long a, long b) {

        for (int i = 1; i <=a; i++) {
            if (a % i == 0 && b % i == 0) {
                return i;

            }
        }
        return 1;
    }
}

Double click to view unformatted code.


Back to problem 59