Skip to content

Instantly share code, notes, and snippets.

@egonelbre
Created April 6, 2012 09:27
Show Gist options
  • Save egonelbre/2318466 to your computer and use it in GitHub Desktop.
Save egonelbre/2318466 to your computer and use it in GitHub Desktop.
simple random number generator in javascript
function newRandom(A,B,seed){
return function(){
seed = (A*seed+B)%(1<<31); return (seed >> 16) & 0x7fff
}
}
r1 = newRandom(69069, 1, 0)
r2 = newRandom(1103515245, 12345, 0)
r3 = newRandom(214013, 2531011, 0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment