OFFSET

1,2

COMMENTS

This sequence and A061364 are generated by the same algorithm but with different seed: A061364 (as well as A096553 which is the sequence of internal states of the generator) has seed 1, while this sequence has seed 0. [Corrected by Jean-Claude Arbaut, Oct 05 2015]

REFERENCES

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

LINKS

FORMULA

Correction of seed value and second formula from David Fifield, May 23 2024: (Start)

x(0) = 0, x(n) = (1103515245 * x(n-1) + 12345) mod 2^31, a(n) = floor(x(n)/2^16).

a(n) = A061364(n + 1212780038). (End)

MATHEMATICA

BitShiftRight[NestList[Mod[#*1103515245 + 12345, 2^31] &, 12345, 50], 16] (* Paolo Xausa, Aug 29 2024 *)

PROG

(C) static unsigned int next = 0; int rand( ) { next = next * 1103515245 + 12345; return ((next >>16) & 32767); }

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

vector(100, n, floor(x(n)/2^16)) \\ Altug Alkan, Oct 05 2015

CROSSREFS

KEYWORD

nonn

AUTHOR

Hugo Pfoertner, Jul 18 2004

EXTENSIONS

Name amended (start at 0) by David Fifield, May 23 2024

STATUS

approved