Description
从键盘输入两个正整数,求这两个正整数的最小公倍数和最大公约数,并输出。
Input
输入包括一行。
两个以空格分开的正整数。
Output
两个整数的最小公倍数和最大公约数。
Sample
Input
6 8
Output
24 2`
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner reader = new Scanner(System.in);
int a, b;
int n = reader.nextInt();
int m = reader.nextInt();
a = n;
b = m;
if (n < m) {
int t = n;
t = m;
m = t;
}
while(m > 0) {
int t = n % m;
n = m;
m = t;
} //辗转相除
System.out.println(a * b / n +" "+n);
reader.close();
}
}