#!/usr/local/bin/ruby # -*- mode: ruby -*- # $Id: random.ruby,v 1.13 2001/05/08 06:35:57 doug Exp $ # http://www.bagley.org/~doug/shootout/ IM = 139968 IA = 3877 IC = 29573 $last = 42.0 def gen_random (max) (max * ($last = ($last * IA + IC) % IM)) / IM end N = Integer(ARGV.shift || 1) result = 0 N.times do result = gen_random(100.0) end printf "%.9f\n", result