I have written some code that is supposed to estimate the value of PI using the Liebniz formula.
When I COUT the result it just says 1.
This might be a stupid question, but what am I doing wrong here?
Here is the code:
int leibnizPi(int n)
for (x=1; x<=n; x++)
if (x%2 == 0)
pi = pi - (1 / ((2*x)-1));
pi = pi + (1 / ((2*x)-1));
Estimation of PI using the Liebniz formula.
Post a Reply
|Oldest Newest Rating|
Used in many types of software including music players, video games, and many large scale applications.
|Bucky Roberts Administrator|