Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include <cmath>
- using namespace std;
- int main()
- {
- double b=1.0/3.0;
- double s=0;
- cout << "e=";
- double e;cin >> e;
- int n=1;
- while (fabs(b)>= e)
- {
- s += b;
- b=-b/9.0;
- n++;
- }
- cout << "s=" << s << endl;
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment