#include <stdio.h>
/* Calculate J(10) from J(0) */
int main(int argc, char **argv)
{
    int n;
    double j= 0.6321205588;  // J(0) estimate 
    // Change the line above to change initial
	// estimate of J(0)

	printf ("Forward iterations \n");

    printf ("Initial estimate: J(0)= %g\n",j);

	// Produce J(10) from J(0)
    for (n= 1; n <= 10; n++) {
        j= 1-(j*n);
        printf ("J(%d)= %g\n",n,j);
    } 
	printf ("\nBackward iterations \n");

	j= 0.84;		// J(10) estimate
	// Change the line above to change initial
	// estimate of J(10)


	printf ("Initial estimate: J(10)= %g\n",j);
    for (n= 10; n > 0; n--) {
        j= (1-j)/n;
        printf ("J(%d)= %g\n",n-1,j);
    } 

    return 0;
}

