Value of e is to be found by the formula

e=1+1/1!+1/2!+1/3!+..................

The following code give value only upto 5!.Although it should increment num and use the new value (ie 5!*6!*7!*..........)again.What's wrong?

Code:#include<iostream> #include<conio.h> using std::cout; using std::cin; using std::endl; int main() { // declare and initialize variable/s int num=5,factorial=1; double result; // display the approx value of e while(num>0) { factorial=factorial*num; num-=1; result=1+factorial; } cout<<"\n\n\t\t\te = "<<1/result; num+=1; getch(); }