Advertisement
Sanlover

Untitled

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