The Computer Language
24.11 Benchmarks Game

too simple Matz's Ruby program

source code

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

# mtime side-effect
open("./one", "w").close()

n = ARGV[0].to_i
sum = 0.0
flip = -1.0
for i in 1..n do
    flip *= -1.0        
    sum += flip / (2*i - 1) 
end
puts "%0.9f" % (sum*4.0)

# mtime side-effect
open("./two", "w").close()
    

notes, command-line, and program output

NOTES:
64-bit Ubuntu quad core
ruby 1.8.7 
(2014-01-28
patchlevel 376)
[x86_64-linux]



 Sun, 22 Sep 2024 02:05:33 GMT

COMMAND LINE:
 /usr/share/rvm/rubies/ruby-1.8.7-head/bin/ruby  toosimple.mri 10000000000

PROGRAM OUTPUT:
3.141592653