4 ms·
iirc Last time I looked at this: public static void main(String[] args) throws FileNotFoundException { Scanner s = new Scanner(new File("rounds.txt
by igouy 10mo ago
iirc Last time I looked at this:
public static void main(String[] args) throws FileNotFoundException {
Scanner s = new Scanner(new File("rounds.txt"));
long rounds = s.nextLong();
s.close();
double sum = 0.0;
double flip = -1.0;
for (long i = 1; i <= rounds; i++) {
flip *= -1.0;
sum += flip / (2 * i - 1);
}
System.out.println(sum * 4.0);
}
:the measurements changed dramatically if the order was switched something like:
sum += flip / (2 * i - 1);
flip *= -1.0;
YMMV
- vips7L 10mo agoIIRC scanner is also terribly slow.