I tried what whiteflags said and got the following results :
with criterion to stop
Code:
while (current > 1.0e-10);
i had to calculate 1073741825 and π=3.14159
With the one i suggest before i calculated 100000 and got p=3,14158 (should be 3.14159..)
Then i changed the criterion to stop to
Code:
while (current > 1.0e-15);
and got the same results with whiteflags's formula as with the previous criterion(that was not expected)
and with the one i had suggested the result is
Code:
Summed 31622777 terms, pi is 3.14159
Of course i have no problem posting the code,but this post ,supposedly,is for a homework of someone(who has lost interest too soon how ever),so i would ask what are the results for you?