i'm still a beginner and i supposed to write this program to find the value of 'e'.

this is the constant e : http://upload.wikimedia.org/math/a/1...d2dd287fdb.png

e is the some of infinite series. the value are suppose to show 2.71828.... but my program shows 2.586834. where did i messed up ? this is how i do so far :

Code:#include <stdio.h> #include <math.h> #include <stdlib.h> int main () { int counter; float value1; float var1 = 0; int var2 = 1; int var4 = 0; float var3 = 1; float var5; float result = 0; for ( counter = 0; counter <= 50; counter++ ) { value1 = var4; while ( value1 > 0 ) { // loop for the factorial var1 = var2 * value1--; var3 = var3 * var1; } // end of factorial loop var5 = 1.0 / var3; result = result + var5; var4++; } printf ("the result is %f", result); getchar (); return 0; }