Calculate pi to an accuracy of 5 decimal places?

Posted by pgras on Programmers See other posts from Programmers or by pgras
Published on 2012-08-30T09:02:34Z Indexed on 2012/08/30 9:50 UTC
Read the original article Hit count: 196

Filed under:

In this message at point 18 I saw following programming question:

Given that Pi can be estimated using the function 4 * (1 – 1/3 + 1/5 – 1/7 + …) with more terms giving greater accuracy, write a function that calculates Pi to an accuracy of 5 decimal places.

So I know how to implement the given function and how to choose how "far" I should calculate, but how can I tell when I've reached the "accuracy of 5 decimal places" ?

© Programmers or respective owner

Related posts about algorithms