Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- using namespace std;
- double Calc(double x, double epsilon){
- double a = - x;
- int i = 1;
- double res = 0;
- while(abs(a) > epsilon){
- res+=a;
- i++;
- a*= - (x*x) / ( (3*i+1) * (3*i+2) * (3*i+3) );
- }
- return res;
- }
- int main() {
- double x,res,epsilon;
- cin >> x >> epsilon;
- res = Calc(x,epsilon);
- cout << res;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement