it4l0

vrum

Dec 14th, 2019
114
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <stdio.h>
  2. int main()
  3. {
  4.      double total = 1, a = 1, b = 1, b2 = 1.5;
  5.      int i = 0, n = 0;
  6.      scanf("%d", &n);
  7.      for (i = 2; i <= n; i++)
  8.      {
  9.           a = a *2; b++;b2 += 1.5;
  10.           if(i % 2 == 0)
  11.           {
  12.                total += a / b2;
  13.           }
  14.           else if(i % 2 != 0)
  15.           {
  16.                total += b / a;
  17.           }
  18.      }
  19.      printf("S: %.2lf", total);
  20.      return 0;
  21. }
RAW Paste Data