程序:
#include<stdio.h> int main(){
int num1,num2,temp1,temp2,r;
scanf("%d %d",&num1,&num2);
temp1 = num1;
temp2 = num2;
while(temp2 != ){
r = temp1 % temp2;
temp1 = temp2;
temp2 = r;
}
printf("%d %d\n",temp1,num1*num2/temp1);
}
求最大公约数:辗转相除法
求最小公倍数:两数相乘除以最大公约数