Skip to content

Instantly share code, notes, and snippets.

@resure
Created March 1, 2011 18:44
Show Gist options
  • Save resure/849626 to your computer and use it in GitHub Desktop.
Save resure/849626 to your computer and use it in GitHub Desktop.
#include <iostream>
using namespace std;
int main()
{
int i,n;
float a=1.0,b=2.0,s=0.0;
cout<<"Input n";
cin>>n;
for(i=1;i!=n;i++)
{
  b = 2 * i;
  s += a / b;
  if (i % 2 == 0) then a += 2;
}
cout << "s = " << s;
getch()
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment