编写函数计算N!,调用该函数计算下式的值:
编写函数计算N!,调用该函数计算下式的值:S=1+1/(1+4!)+1/(1+4!+7!)+`````+1/(1+4!+7!+```````+19!)
#include "stdio.h" double fact(int x) { double item=1,i; for (i=1;i<=x;i++) item*=i; return item; } double add(int y) { double sum; int i; sum=0; for (i=1;i<=y;i=i+3) sum+=1/fact(i); return sum; } void main() { double s; s=add (19); printf("the result is : %lf\n",s); }