Advertisement
kirya_shkolnik

Зимовец - 3

Feb 24th, 2021
298
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.41 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3. using namespace std;
  4.  
  5. double Calc(double x, double epsilon){
  6.     double a = - x;
  7.     int i = 1;
  8.     double res = 0;
  9.     while(abs(a) > epsilon){
  10.         res+=a;
  11.         i++;
  12.         a*= - (x*x) / ( (3*i+1) * (3*i+2) * (3*i+3) );
  13.     }
  14.     return res;
  15. }
  16. int main() {
  17.     double x,res,epsilon;
  18.     cin >> x >> epsilon;
  19.     res = Calc(x,epsilon);
  20.     cout << res;
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement