Advertisement
Sanlover

Untitled

Nov 18th, 2021
686
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.56 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5.   double a, x;
  6.   int k;
  7.  
  8.   cout << "Etner A: ";
  9.   cin >> a;
  10.   cout << "Enter K: ";
  11.   cin >> k;
  12.   if (k <= 0 && k % 2 != 0) {
  13.     cout << "K must be positive and even";
  14.     return 0;
  15.   }
  16.   cout << "Enter X: ";
  17.   cin >> x;
  18.  
  19.   double summary = 1;
  20.   for (int i = 2; i <= k; i += 2) {
  21.     if (i == 2) {
  22.       summary = (a - x / i) * (a - x / i);
  23.     } else {
  24.       summary = (summary - x / i) * (summary - x / i);
  25.     }
  26.   }
  27.   summary *= 5;
  28.   summary -= 3;
  29.   cout << summary;
  30.   return 0;
  31. }
  32.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement