#include <stdio.h>
int getgcd(int a, int b)
{
int temp ;
if(b>a)
{
temp =a;
a=b;
b=temp;
}
int r=a%b;
while(r !=0)
{
a=b;
b=r;
r=a%b;
}
return b;
}
int main()
{
int x,y;
scanf("%d %d",&x,&y);
int gcd=getgcd(x,y);
int lcm;
lcm=x*y/gcd;
printf("%d %d",gcd,lcm);
}
沒有留言:
張貼留言