This is my code and i'm trying to calculate this series : ((-1)^n)*n/(n+1)
that n started from 1
to 5
, code is not working correctly, anyone can help ?
int main(){
int i,n;
double sum1;
for (i=1; i<6; i++)
sum1 += (pow(-1,i))*((i)/(i+1));
cout<<sum1;
return 0;
}
The true answer at the end must be equal to -0.6166666666666667
which code cant calculate it correctly.
I calculated series from here. Is there any special function to do summation ?