Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <cstdlib>
- #include <iostream>
- #include <math.h>
- #include <cmath>
- using namespace std;
- double esx(double x, double epsl);
- int main(int argc, char** argv) {
- double x;
- double epsl;
- cout << "Enter value a X:" << endl;
- cin >> x;
- cout << "Enter value a Epsl:" << endl;
- cin >> epsl;
- double x1 = (1/(1-x));
- cout << "x=" << x1 << endl << "x1=" << esx(x,epsl) << endl;
- system("pause");
- return 0;
- }
- double esx(double x, double epsl){
- int n=0;
- double s = 1;
- double p = s;
- double xn=x;
- do{
- for(int i=1;i<=n;++i){
- xn=xn*x;
- }
- p=p+xn;
- s=xn;
- xn=x;
- n++;
- }while(fabs(s)>epsl);
- return p;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement