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