Advertisement
RadioNurshat

ZSeries

Sep 27th, 2020
1,481
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.37 KB | None | 0 0
  1.  
  2. #include <iostream>
  3. #include <math.h>
  4. using namespace std;
  5.  
  6. double calculate(double z, int n) {
  7.     double last = 1.0 + z;
  8.     double series = 1;
  9.     for (int i = 1; i < n; i++) {
  10.         series = series * last;
  11.         last = last * z + 1.0;
  12.     }
  13.     return series*last;
  14. }
  15. int main()
  16. {
  17.     double z = 0;
  18.     cin >> z;
  19.     int n = 0;
  20.     cin >> n;
  21.     cout << round(calculate(z, n)*1000)/1000;
  22. }
  23.  
  24.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement