Paste Search Dynamic
Recent pastes
formula
  1. #include <iostream>
  2. #include <cmath>
  3.  
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8.     const double E = 0.00001;
  9.  
  10.     double s = 0;
  11.     double x, a, a1;
  12.     cout << "Input x: ";
  13.     cin >> x;
  14.  
  15.     a = pow((x - 1) / (x + 1), 3) * (1 / 3);
  16.     int k = 1;
  17.     do
  18.     {
  19.         a1 = a;
  20.         //formula
  21.         a *= pow((x - 1) / (x + 1), 2) * ((2 * k + 1) / (2 * k + 3));
  22.         s += a;
  23.         k++;
  24.     } while (fabs(a1 - a > E));
  25.  
  26.     cout << "summa = " << s << endl
  27.          << "kol = " << k << endl;
  28.     return 0;
  29. }
  30.  
  31.  
Parsed in 0.003 seconds