-- $Id: random.lua,v 1.12 2001/05/08 01:36:50 doug Exp $ -- http://www.bagley.org/~doug/shootout/ -- implemented by: Roberto Ierusalimschy local IM = 139968 local IA = 3877 local IC = 29573 LAST = 42 function gen_random(max) LAST = mod((LAST * %IA + %IC), %IM) return( (max * LAST) / %IM ) end local N = tonumber((arg and arg[1])) or 1 local result = 0 for i=N, 1, -1 do result = gen_random(100) end write(format("%.9f\n", result))