Advertisement
SergeyPGUTI

3.2.9

Sep 30th, 2015
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.28 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3.  
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8.     int n;
  9.     double Sum=0;
  10.     cin>>n;
  11.     int k=0;
  12.     for (int i=0;i<=n;i++)
  13.     {
  14.         if(i%2==0) k=1; else k=-1;
  15.         Sum+=k*1.0/(2*i+1);
  16.     }
  17.  
  18.     cout<<Sum*4;
  19.     return 0;
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement