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