You've made a couple of errors:
When you declare "double x" you should really also assign it to zero, i.e.
long double x=0;In the loop, your code is all wrong, try:
for (int n = 2; n <= i; n++) { x += 1/pow(n,2.0); } pi =sqrt(6*(1+x));You'l notice you don't need n=1, because you've included this result explicitly in the last line above. You don't need to use long int, the int will be easily sufficient for anything you need. If you're going to use a long double for pi, then you should use the same for x. Hope this helps.
Login