Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <math.h>
- using namespace std;
- double calculate(double z, int n) {
- double last = 1.0 + z;
- double series = 1;
- for (int i = 1; i < n; i++) {
- series = series * last;
- last = last * z + 1.0;
- }
- return series*last;
- }
- int main()
- {
- double z = 0;
- cin >> z;
- int n = 0;
- cin >> n;
- cout << round(calculate(z, n)*1000)/1000;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement