Skip to content

Instantly share code, notes, and snippets.

@allex
Created September 16, 2012 13:59
Show Gist options
  • Save allex/3732560 to your computer and use it in GitHub Desktop.
Save allex/3732560 to your computer and use it in GitHub Desktop.
LCG_random
// http://en.wikipedia.org/wiki/Linear_congruential_generator
var LCG = function(seed) {
return function () {
seed = (214013 * seed + 2531011) % 0x100000000;
return seed * (1.0 / 4294967296.0);
};
};
var random = LCG(10);
console.log(random());
console.log(random());
console.log(random());
console.log(random());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment