Skip to content

Instantly share code, notes, and snippets.

@jaburns
Last active February 7, 2021 18:29
Show Gist options
  • Save jaburns/6ea2bbd4333d93748ff033f47e3096b7 to your computer and use it in GitHub Desktop.
Save jaburns/6ea2bbd4333d93748ff033f47e3096b7 to your computer and use it in GitHub Desktop.
Linear congruential random-number generator.
const M = 4294967296;
const A = 1664525;
const C = 1013904223;
// seed is an integer in the range [0, M)
const next = seed => (A * seed + C) % M;
const value = seed => seed / M;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment