How to Generate a Sequence of Unique Random Integers (2012) Posted by vince14 on Monday December 21, 2020 @12:52PM from the preshing.com dept. https://preshing.com/20121224/how-to-generate-a-sequence-of-unique-random-integers/ ( 1 comment | 4 points | on HN )
A simple LCG is of the form
seed <- A*seed + B
Start with any seed, in 32 bit unsigned int, assume 32 bit wrapping like in C/C++, etc. (or do mod yourself), pick good A and B, and away you go.
The Hull–Dobell Theorem tells you how to pick A and B for this size m=2^32: A and B are both odd and larger than 1 and A-1 is divisible by 4.
Finding nice A and B is a bit tricky - in which case look online for good choices or related theory.
Of course, a LCG may not be as random as you like. In that case one of the PCG variants solve the problem elegantly.