2或者3个数,求他的最大公约数和最小公倍数 求1*2*3,...100的积,要求用调和函数 C语言题目,麻烦各位大虾

如题所述

第1个回答  2011-12-21
#include <stdio.h>
int gcd(int a,int b)
{int temp;
if (a<b)
{temp=a;
a=b;
b=temp;
}
while(b!=0)
{temp=a%b;
a=b;
b=temp;
}
return a;
}
main()
{int a,b;
scanf("%d%d",&a,&b);
printf("zuidagongyueshu\n:%d",gcd(a,b));
printf("zuixiaogongbeishu\n:%d",a*b/gcd(a,b));
}
上面是求2个数最大公约数和最小公倍数,求1-2-3...100的积,出来的数据太大,难于存储追问

我操作过,不正确

第2个回答  2011-12-22
递归求一到一百。
int fun(int a)
{
if(a==1)return 1;
else return fun(a-1)*a;
}//传个100给a就行了。