Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <iomanip>
- #include <cmath>
- int main()
- {
- auto x{ 0.0 },
- e{ 0.0 };
- auto n{ 3 };
- std::cin >> x >> e;
- auto yr{ x }, yr2{ std::pow(x, n) / n };
- auto sum{ 0.0 };
- while (std::abs(yr2 - yr) >= e)
- {
- sum += yr;
- yr = yr2;
- n += 2;
- yr2 = std::pow(x, n) / n;
- }
- std::cout << std::fixed << std::setprecision(6) << sum;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement