import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class test05 {
/**
* @param args
* @throws IOException
*/
public static void main(String[] args) throws IOException {
// TODO Auto-generated method stub
BufferedReader in1=new BufferedReader(new InputStreamReader(System.in));
int j=Integer.parseInt(in1.readLine());
BufferedReader in2=new BufferedReader(new InputStreamReader(System.in));
int i=Integer.parseInt(in2.readLine());
test05 one =new test05();
int m=one.maxCommonDivisor(j, i);
int n=one.minCommonMultiple(j, i);
System.out.println(m);
System.out.println(n);
}
int maxCommonDivisor(int m, int n)
{
if (m % n == 0)
{
return n;
}
else
{
return maxCommonDivisor(n, m % n);
}
}
int minCommonMultiple(int m, int n)
{
return m * n /(maxCommonDivisor(m, n));
}
}
最大公约数和最小公倍数
最新推荐文章于 2022-04-16 17:07:48 发布