/*
 * Calculate the integral I_n = \int_0^1 x^n e^(-x) dx
 * using the (unstable) forward recurrence relation
 *
 * I_{n} = n*I_{n-1} - 1/e
 */

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

int main (void)
{
    int i, n = 16;
    double I;

    I = 1. - 1./M_E;

    for (i = 1; i < n; i++)
    {
        I = -1./M_E + i*I;
        printf ("%3d   % 24.14f\n", i, I);
    }

    return 0;
}