Book 4-4
#include<math.h>
void main()
{ double s,t;
int x;
t=1,x=1;s=1;
do
{x=x+1;
t=-t/x;
s=s+t;
}while(fabs(t)>=1e-7);
printf("1-1/2!+1/3!-1/4!+...+(-1)^n-1/n!=%.6f",s);
getch();
}
#include<math.h>
void main()
{ double s,t;
int x;
t=1,x=1;s=1;
do
{x=x+1;
t=-t/x;
s=s+t;
}while(fabs(t)>=1e-7);
printf("1-1/2!+1/3!-1/4!+...+(-1)^n-1/n!=%.6f",s);
getch();
}