Talk:Linear congruential generator: Difference between revisions

Content added Content deleted
(→‎On the task: Seed 0 is bad when c = 0.)
Line 17: Line 17:
:::*<math>r_{n + 1} = 7^5 \times r_n \pmod {2^{31} - 1}</math>
:::*<math>r_{n + 1} = 7^5 \times r_n \pmod {2^{31} - 1}</math>
:::If the program tries <math>r_0 = 0</math>, then FreeBSD uses <math>r_0 = 123459876</math>. --[[User:Kernigh|Kernigh]] 04:23, 15 July 2011 (UTC)
:::If the program tries <math>r_0 = 0</math>, then FreeBSD uses <math>r_0 = 123459876</math>. --[[User:Kernigh|Kernigh]] 04:23, 15 July 2011 (UTC)
::::Huh, how does that work? <math>2^{31}-1</math> is a prime number, so no <math>r_n</math> will ever produce a 0 return value. <code>RAND_MAX</code> presumably is <math>2^{31}-2</math>? Aren't <code>rand()</code> supposed to return a value from 0 to <code>RAND_MAX</code> inclusive? --[[User:Ledrug|Ledrug]] 07:52, 15 July 2011 (UTC)


== Example Sequences==
== Example Sequences==