Advertisement
Guest User

Untitled

a guest
Nov 17th, 2019
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.45 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3.  
  4. using namespace std;
  5.  
  6. double sumSequence (int n, int quantity, double s) {
  7.     s += pow(-1, n)/((n*n + 2)*(n-1));
  8.     if (n < quantity) return sumSequence(n+1, quantity, s);
  9.     else return s;
  10. }
  11.  
  12. int main() {
  13.     int quantity;
  14.     double accuracy, ans;
  15.     cin >> quantity >> accuracy;
  16.     ans = sumSequence(2, quantity, 0);
  17.     if (ans < accuracy) cout << "None";
  18.     else cout << ans;
  19.     return 0;
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement