/*计算1!+2!+…+100!。要求定义和调用函数fact(n)计算n的阶乘*/ #includedouble fact(int n);int main(void){ int i; double sum; sum=0; for(i=1;i<=100;i++) sum=sum+fact(i); /*阶乘相加*/ printf("1!+2!+……+100!=%e\n",sum); return 0;}double fact(int n) /*计算n的阶乘*/{ int i; double result; result=1; for(i=1;i<=n;i++) result=result*i; return result;}