java - Calculate pi using Leibniz series -
i'm new java , i'm trying make program calculates pi using leibniz series 100000 iterations. need define method , call it. when run program don't result. please tell me i'm doing wrong , me on track?
public class pi { public static void main(string[] args) { double pi = computepi(100000); } public static double computepi(int count) { double pi = 0; count = 100000; for(int =0; i<count; i++) { pi = math.pow(-1,i)/(2*i+1); } return pi; } }
if want print console, try:
public static void main(string[] args) { system.out.println("pi = " + calculatepi(100000)); }
i can't precision, though.
Comments
Post a Comment