Created
September 16, 2012 13:59
-
-
Save allex/3732560 to your computer and use it in GitHub Desktop.
LCG_random
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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