Java 풀이
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner num = new Scanner(System.in);
int a = num.nextInt();
int b = num.nextInt();
int num1 = 0;
int num2 = 0;
for (int i = 1; i < a + 1; i++) {
if (a % i == 0 && b % i == 0) {
num1 = i;
}
}
num2 = (a * b) / num1;
System.out.println(num1 +"\n"+num2);
}
}