Advertisement
Josif_tepe

Untitled

Nov 21st, 2023
425
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.50 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. double funkcija(int n) {
  4.     double result = 0.5;
  5.     int brojac = 1;
  6.     for(int i = 3; i <= n; i += 2) {
  7.         if(brojac % 2 == 0) {
  8.             result /= ( (double)i / (double)(i + 1) );
  9.         }
  10.         else {
  11.             result *= ( (double)i / (double)(i + 1) );
  12.         }
  13.         brojac++;
  14.     }
  15.     return result;
  16. }
  17. int main (int argc, const char * argv[]) {
  18.     int n;
  19.     scanf("%d", &n);
  20.    
  21.    
  22.     printf("%lf\n", funkcija(n));
  23.    
  24.     return 0;
  25. }
  26.  
  27.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement