<< 接上篇

a0 = -(1/e - 1)
a1 = +(1/e - 0)
a2 = -(2/e - 1)
a3 = +(6/e - 2)
a4 = -(24/e - 9)
a5 = +(120/e - 44)
a6 = -(720/e - 265)

an = (-1)n+1(n!/e - bn)

an = (-1)n+1(n!/e - !n)

``````#include <stdio.h>
#include <math.h>

double a(int n)
{
double v = 0, t = 1;
for (n++; t != 0; n++) t /= n, v += t, t = -t;
return v;
}

int main(void)
{
double v = 1 - 1 / M_E;
for (int i = 1; i <= 1000; v = 1 - i++ * v)
if (i < 5 || (i > 15 && i < 23) || i > 998)
printf("a(%3d): %.12lf %16.12lf\n", i-1, a(i-1), v);
}
``````

``````a(  0): 0.632120558829   0.632120558829
a(  1): 0.367879441171   0.367879441171
a(  2): 0.264241117657   0.264241117657
a(  3): 0.207276647029   0.207276647029
a( 15): 0.059017540879   0.059033793642
a( 16): 0.055719345931   0.055459301730
a( 17): 0.052771119169   0.057191870597
a( 18): 0.050119854958  -0.029453670752
a( 19): 0.047722755796   1.559619744279
a( 20): 0.045544884076 -30.192394885584
a( 21): 0.043557434408 635.040292597259
a(998): 0.001000000999             -inf
a(999): 0.000999001995              inf
``````

>> 接下篇