Advertisement
Josif_tepe

Untitled

Oct 17th, 2021
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.39 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. using namespace std;
  4. int n;
  5. double niza[105];
  6. double rec(int i, double result) {
  7.     if(i == 0) {
  8.         return result;
  9.     }
  10.     return rec(i - 1, 1.0 / (result + niza[i]));
  11. }
  12. int main()
  13. {
  14.     cin >> n;
  15.     for(int i = 0; i < n; i++) {
  16.         cin >> niza[i];
  17.     }
  18.     cout << rec(n - 1, 0.0) + niza[0] << endl;
  19.    
  20.     return 0;
  21. }
  22.  
  23.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement