Write a program to calculate the result of the formula pi in java π=4(1β1/3+1/5β1/7+1/9β1/11+1/13ββ―β1/2πβ1+1/2π+1) with 10000 β€ i β€ 100000
public class Pi { public static void main(String[] args) { double pi = 0.0; System.out.println("i m(i)"); System.out.println("-----------------------"); for (int i = 10000; i <= 100000; i += 10000) { pi = 0.0; for (int j = 1; j <= i; j++) { if (j % 2 == 0) { pi += 1.0 / (2 * j - 1); } else { pi -= 1.0 / (2 * j - 1); } } pi *= 4.0; System.out.printf("%d\t\t%10.4f\n", i, pi); } } }