i need some help on my pi approximation it's really slow. compile it and see for your self. i think my problem is with my math. it comes out with the wrong first few numbers. i'm trying to use gregory's formula or the advanced version of it.
#include <iostream>
#include <conio.h>
using namespace std;
void main()
{
long double ans=4,l=1;
cout<<ans<<endl;
for(int i=1;i<=100000000;i++)
{
l++;
if(i % 2 == 1)
{
ans=(ans-1/(2*l +1));
}
if(i % 2 == 0)
{
ans=(ans+1/(2*l+1));
}
system("cls");
cout<< ans <<endl;
}
_getch();
}