The Computer Language
24.04 Benchmarks Game

too simple Perl program

source code

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

my $n = shift;
my $sum = 0.0;
my $flip = -1.0;
for my $i (1..$n) {
    $flip *= -1.0;        
    $sum += $flip / (2*$i - 1); 
}
printf( "%0.9f\n", ($sum*4.0));
    

notes, command-line, and program output

NOTES:
64-bit Ubuntu quad core
This is perl 5, version 38
subversion 2 (v5.38.2)
x86_64-linux-thread-multi


 Sun, 03 Mar 2024 01:07:30 GMT

COMMAND LINE:
 /opt/src/perl-5.38.2/bin/perl toosimple.perl 10000000000

PROGRAM OUTPUT:
3.141592653