这个阶乘怎么求和啊!求教~~
#include<stdio.h>long fact(long n);
double s(int x);
int main()
{
int x;
printf("enter :");
scanf("%d",&x);
printf("\ns(%d)=%f",x,s(x));
return 0;
}
long fact(long n);
{
int i,t;
long s=1;
for (i=1;i<=n;i++)
{
if(i%2==0) continue;
else
{
s=s*i;
t=t+s;
}
}
return n;
}
double s(int x)
{
double result=1.0,tmp;
int i=1,sign=1;
do{
tmp=sign/i*fact(i++);
sign=-sign;
result+=tmp;
}while(tmp>=1e-6);
return result;
}