Linear congruential generator: Difference between revisions

In the task description, add the range of BSD and Microsoft rand_n, attempting to prohibit solutions like the F# code that yields numbers out of range.
m (seed_n => state_n)
(In the task description, add the range of BSD and Microsoft rand_n, attempting to prohibit solutions like the F# code that yields numbers out of range.)
Line 22:
* <math>state_{n + 1} = 1103515245 \times state_n + 12345 \pmod{2^{31}}</math>
* <math>rand_n = state_n</math>
* <math>rand_n</math> is in range 0 to 2147483647.
 
Microsoft formula:
Line 27 ⟶ 28:
* <math>state_{n + 1} = 214013 \times state_n + 2531011 \pmod{2^{31}}</math>
* <math>rand_n = state_n \div 2^{16}</math>
* <math>rand_n</math> is in range 0 to 32767.
 
The BSD formula was so awful that FreeBSD switched to a different formula. More info is at [[Random number generator (included)#C]].
Anonymous user