Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- using namespace std;
- double sumSequence (int n, int quantity, double s) {
- s += pow(-1, n)/((n*n + 2)*(n-1));
- if (n < quantity) return sumSequence(n+1, quantity, s);
- else return s;
- }
- int main() {
- int quantity;
- double accuracy, ans;
- cin >> quantity >> accuracy;
- ans = sumSequence(2, quantity, 0);
- if (ans < accuracy) cout << "None";
- else cout << ans;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement