Skip to content

Instantly share code, notes, and snippets.

@rangercyh
Created September 26, 2014 09:28
Show Gist options
  • Save rangercyh/8abff917b1f58839968a to your computer and use it in GitHub Desktop.
Save rangercyh/8abff917b1f58839968a to your computer and use it in GitHub Desktop.
linear congruence generate random number
local IA = 3877
local IB = 29573
local g_seed = 42
function setseed(seed)
g_seed = seed
end
function getrandom(max)
max = max or 100
g_seed = g_seed * IA + IB
return g_seed % max
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment