Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- using namespace std;
- int main()
- {
- int n;
- double Sum=0;
- cin>>n;
- int k=0;
- for (int i=0;i<=n;i++)
- {
- if(i%2==0) k=1; else k=-1;
- Sum+=k*1.0/(2*i+1);
- }
- cout<<Sum*4;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement