A pseudorandom number is a number generated by a deterministic procedure intended to imitate a random number. The prefix pseudo- distinguishes such numbers from results obtained from a random physical process such as radioactive decay.
An early example is the middle-square method (von Neumann 1951). For a decimal state
of width
with
a positive integer, square
, pad the square on the left with zeros to width
, and retain the middle
digits as the next state. In arithmetic terms the next state
is the remainder of
modulo
.
There are only
states. Once a state repeats, determinism forces all later states to repeat with
the same period, so the sequence is eventually periodic with period at most
. This bound does not ensure a long cycle. For
example, with width four the seed 2500 yields 2500 again because its padded square
is 06250000. The state zero is also fixed.