
Wondering how you could implement a Linear-Feedback Shift Register PRNG as 3 JavaScript functions: 8-bit, 16-bit, and 32-bit versions which take x as input and return a new x, never encountering a duplicate number until you start over. Uint16_t start_state = 0xACE1u /* Any nonzero start state will work. I don't quite understand the C code though: # include One of the best answers as far as I can tell is the Linear-Feedback Shift Register one. The question Unique (non-repeating) random numbers in O(1)? doesn't get directly answered with an implementation, and it's hard to see how to apply it.


I am looking for a PRNG that works in O(1) time and never encounters a duplicate number as you increment through the values.
