Advertisement
kostes

1bb

Jan 15th, 2019
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.46 KB | None | 0 0
  1. #include <iostream>
  2. #include <math.h>
  3. using namespace std;
  4. int main()
  5. {
  6. double e;
  7. cout << "vvedite e\n";
  8. cin >> e;
  9. double sum = 0;
  10. double a = e;
  11. int n = 1;
  12. while(fabs(a) >= e)
  13. {
  14. double f = 1;
  15. for(int i = 0; i < n; i++)
  16. f *= 2;
  17. double s = 1;
  18. for(int i = 0; i < n; i++)
  19. s *= 3;
  20. a = (double) f / s;
  21. sum += a;
  22. n++;
  23. }
  24. cout << sum;
  25. return 0;
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement