[mw_shl_code=c,true]//整数的最大公约数和最小公倍数
#include <stdio.h>
#include <stdlib.h>
//最大公约数(辗转相除)greatest common divisor
int gcd(int a,int b)
{
int t;
while(a%b!=0)
{
t=a%b;
a=b;
b=t;
}
return b;
}
//最小公倍数 least common multiple
int lcm(int a,int b)
{
return a*b/gcd(a,b);
}
int main()
{
int a,b;
scanf("%d %d",&a,&b);
printf("%d %d\n",gcd(a,b),lcm(a,b));
system("pause");
return 0;
}
[/mw_shl_code]
|