int main()
{
double sum = 1.;
double t = 3.;
while( fabs(1 / t) >= 10E-9 )
{
t = -1 / t;
sum += t;
if(t < 0)
{
t = 1 / t - 2;
}
else
{
t = 1 / t + 2;
}
}
double PI = sum * 4;
return 0;}
int main()
{
double sum = 1.;
double t = 3.;
for(; fabs(1 / t) >= 10E-9; )
{
t = -1 / t;
sum += t;
if(t < 0)
{
t = 1 / t - 2;
}
else
{
t = 1 / t + 2;
}
}
double PI = sum * 4;
return 0;
}
int main()
{
double sum = 1.;
double t = 3.;
do{
t = -1 / t;
sum += t;
if(t < 0)
{
t = 1 / t - 2;
}
else
{
t = 1 / t + 2;
}
}while( fabs(1 / t) >= 10E-9 );
double PI = sum * 4;
return 0;
}