OFFSET
0,3
COMMENTS
A widely used pseudo-random number generator, for example all Delphi-Versions until now use it for their "Random" function.
It can be shown that the sequence has full period (its length is 2^32).
LINKS
T. D. Noe, Table of n, a(n) for n = 0..1000
Wikipedia, Linear congruential generator
FORMULA
a(n+1) = (134775813 * a(n) + 1) (mod 2^32) (representatives for the equivalence classes by interpreting the bit-patterns as two's complement).
MATHEMATICA
nn=30; t = {x = 0}; Do[x = Mod[134775813 x + 1, 2^32]; If[x > 2^31, x = x - 2^32]; AppendTo[t, x], {nn}]; t (* T. D. Noe, Dec 18 2012 *)
PROG
(Delphi) // implementation using Delphi's built-in random() function
var
I: Integer;
begin
Randseed:= 0;
for I:= 1 to 100 do begin
Write(Randseed, ', ');
Random;
end;
end.
(PARI) step(n)=(134775813*n+1)%2^32 \\ Charles R Greathouse IV, Sep 10 2015
(PARI) a(n)=lift((Mod(134775813, 2^34)^n-1)/33693953)/4 \\ Charles R Greathouse IV, Sep 10 2015
CROSSREFS
KEYWORD
sign,easy
AUTHOR
Moritz Franckenstein, Dec 16 2008
STATUS
approved