Advertisement
Taraxacum

Estimate e with Taylor Series

Oct 8th, 2018
288
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.30 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main(int argc, char const* argv[])
  6. {
  7.     double e = 1, dlt = 1;
  8.  
  9.     int fact = 1;
  10.     int idx = 1;
  11.  
  12.     while (dlt > 1e-7) {
  13.         fact *= idx++;
  14.         dlt = 1.0 / fact;
  15.         e += dlt;
  16.     }
  17.    
  18.     cout << e << endl;
  19.  
  20.     return 0;
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement