Advertisement
Josif_tepe

Untitled

Dec 24th, 2020
203
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.60 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4. #include <ctype.h>
  5. int niza[105];
  6.  
  7. double rekurzija(int at, double sum_do_drobna_crta_pred_at) { // indeks vo nizata
  8.     if(at == 0) {
  9.         return sum_do_drobna_crta_pred_at;
  10.     }
  11.     return rekurzija(at - 1, (double) 1.0 / (sum_do_drobna_crta_pred_at + niza[at]));
  12.    
  13. }
  14. int main()
  15. {
  16.     int n;
  17.     scanf("%d", &n);
  18.     for(int i = 0; i < n; i++) {
  19.         scanf("%d", &niza[i]);
  20.     }
  21.     double rezultat = rekurzija(n - 1, 0.0);
  22.     rezultat += (double) niza[0];
  23.     printf("%f\n", rezultat);
  24.    
  25.          return 0;
  26. }
  27.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement