public static void main(String[] args) {
double pi = 0;
for (int i = 0; i<1000000000; i++) {
double next = 4 * (i % 2 == 0 ? (1.0 / (i*2+1)) : -(1.0 / (i*2+1)));
pi = pi + next;
}
System.out.println(pi);
Sign in to make a reply
yukigashizukanifutteiru
public static void main(String[] args) {
double pi = 0;
for (int i = 0; i<1000000000; i++) {
double next = 4 * (i % 2 == 0 ? (1.0 / (i*2+1)) : -(1.0 / (i*2+1)));
pi = pi + next;
}
System.out.println(pi);
}