All pastes #615665 Raw Edit

Stuff

public text v1 · immutable
·published 2007-07-12 07:33 UTC
rendered paste body
int factorial(int num) {
   if (num == 1)
      return 1;

   return factorial(num-1) * num;
}

void CalcEtoPI(ofstream&fout)
{ 
     double total=1.0;
     for(double x=1.0; x<=20.0; x+=1.0)
     { 
      const double PI=3.14;
      double newterm;
      
      newterm=1.0/factorial(x)*pow(PI,x);
      
      total=total+newterm;    
        
      fout<<total<<endl;
      cout<<total<<endl;  
      
     }     
    
  
}