computePI(int n) – One remarkably simple formula for approximating the value of pi is the so-called Madhava–Leibniz series: pi/4 = 1 − 1/3+1/5 −1/7 +1/9 − ⋯ +/− 1/2n-1. Note that the result of the series is a quarter of pi. The accuracy of the approximation is dependent on the value of n. This method takes an int parameter n and calculates the value of pi, rather than pi/4. Pay attention to the sign (positive or negative) of each term.
public double computePI(int n) { // TODO: implement this method return -1; //replace this statement with your own return;
}
Already registered? Login
Not Account? Sign up
Enter your email address to reset your password
Back to Login? Click here