Xn+1 = (a * Xn + c) mod m
where a, c and m are constants. An example:
Xn | aXn + c | Xn+1 |
---|---|---|
7 | 7*7 + 7 = 56 | 6 |
6 | 7*6 + 7 = 49 | 9 |
9 | 7*9 + 7 = 70 | 0 |
0 | 7*0 + 7 = 7 | 7 |
This is obviously not a great RNG: it cycles back to the original seed value after just 4 values.
A minimal standard RNG, according to Park and Miller (1988):
a = 16807 c = 0 m = 231-1 = 2147483647
Period: 231-2 = approx 2.1*109
Note that an ordinary Pentium III will exhaust this period in less than one CPU hour!