Advertisement
Josif_tepe

Untitled

May 31st, 2021
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.43 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. double rekurzija(int *niza, int i, double broj) {
  5.     if(i == 0) {
  6.         return broj + niza[0];
  7.     }
  8.     return rekurzija(niza, i - 1, 1.0 / (broj + niza[i]));
  9. }
  10. int main() {
  11.     int n;
  12.     scanf("%d", &n);
  13.     int niza[n];
  14.     for(int i = 0; i < n; i++) {
  15.         scanf("%d", &niza[i]);
  16.     }
  17.     printf("%f\n", rekurzija(niza, n - 1, 0));
  18.     return 0;
  19. }
  20.  
  21. // 7 3 7 15 1 292 1 1
  22.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement