Advertisement
Josif_tepe

Untitled

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