The Computer Language
24.04 Benchmarks Game

too simple Java program

source code

/* The Computer Language Benchmarks Game
   https://salsa.debian.org/benchmarksgame-team/benchmarksgame/
*/

class toosimple {
public static void main(String[] args) {   
    long n = Long.parseLong(args[0]);
    double sum = 0.0;
    double flip = -1.0;
    for (long i = 1; i <= n; i++) {    
        flip *= -1.0;        
        sum += flip / (2*i - 1);               
    }                        
    System.out.printf("%.9f\n", sum*4.0);   
}
}
    

notes, command-line, and program output

NOTES:
64-bit Ubuntu quad core
java 22 2024-03-19
Java HotSpot(TM) 64-Bit Server VM
(build 22+36-2370, 
mixed mode, sharing)


 Wed, 20 Mar 2024 07:07:41 GMT

MAKE:
mv toosimple.java toosimple.java
mv: 'toosimple.java' and 'toosimple.java' are the same file
make: [/home/dunham/all-benchmarksgame/2000-benchmarksgame/nanobench/makefiles/u64q.programs.Makefile:266: toosimple.java_run] Error 1 (ignored)
/opt/src/jdk-22/bin/javac -d .  toosimple.java

1.53s to complete and log all make actions

COMMAND LINE:
 /opt/src/jdk-22/bin/java   toosimple 10000000000

PROGRAM OUTPUT:
3.141592653