import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); String[] split = scanner.nextLine().split(" "); Integer n1 = Integer.valueOf(split[0]); Integer n2 = Integer.valueOf(split[1]); int x = n1 > n2 ? n1 : n2; int y = n1 + n2 - x; while (x != 0) { int temp = y % x; y = x; x = temp; } System.out.println(n1 * n2 / y + " " + y); } } |
Double click to view unformatted code.