login
Consecutive states of the linear congruential pseudo-random number generator used in function rand() in the Standard C library (VAX C) when started at 1.
3

%I #28 Oct 27 2023 20:41:24

%S 1,1103527590,377401575,662824084,1147902781,2035015474,368800899,

%T 1508029952,486256185,1062517886,267834847,180171308,836760821,

%U 595337866,790425851,2111915288,1149758321,1644289366,1388290519,1647418052,1675546029

%N Consecutive states of the linear congruential pseudo-random number generator used in function rand() in the Standard C library (VAX C) when started at 1.

%C This is also the sequence of internal states of the generator described in Kernighan and Ritchie, which produces output limited to 15bit, see A061364. - A-number corrected by _Jean-Claude Arbaut_, Oct 05 2015

%D Brian W Kernighan and Dennis M. Ritchie, The C Programming Language (Second Edition) Prentice Hall Software Series, 1988.

%H Alois P. Heinz, <a href="/A096553/b096553.txt">Table of n, a(n) for n = 1..10000</a> (first 1000 terms from Harvey P. Dale)

%H <a href="/index/Ps#PRN">Index entries for sequences related to pseudo-random numbers.</a>

%F a(1)=1, a(n) = (1103515245 * a(n-1) + 12345) mod 2^31.

%p a:= proc(n) option remember; `if`(n<2, n,

%p irem(1103515245 *a(n-1)+12345, 2147483648))

%p end:

%p seq(a(n), n=1..30); # _Alois P. Heinz_, Jun 10 2014

%t With[{c=2^31},NestList[Mod[1103515245#+12345,c]&,1,20]] (* _Harvey P. Dale_, Aug 01 2012 *)

%o (PARI) a(n) = if(n<2, 1, (1103515245 * a(n-1) + 12345) % (2^31));

%o vector(100, n, a(n)) \\ _Altug Alkan_, Oct 05 2015

%o (Magma) [n eq 1 select 1 else (1103515245 * Self(n-1) + 12345) mod (2^31): n in [1..25]]; // _Vincenzo Librandi_, Oct 06 2015

%Y Cf. A096550-A096561 for other pseudo-random number generators.

%K nonn

%O 1,2

%A _Hugo Pfoertner_, Jul 18 2004