c語言用函數求最大公倍數和最小公約數
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<algorithm>
using namespace std;
int main()
{
int a,b;
scanf("%d%d",&a,&b);
int c=__gcd(a,b);
printf("%d\n",c);//求出最大公約數
int d=a*b;//推理可知最小公倍數是兩個數乘積除於最大公約數
int e=d/c;
printf("%d\n",e);//求出最小公倍數
return 0;
}