The actual answer is that it depends on the implementation of the generator, which is not defined in the standard. This is true even for Linear Congruential Generators (LCGs), which are often used as a default implementation for rand
.
An LCG is a recurrence relationship of the form
state = (A * state + B) % M
for suitable integer-valued constants A
, B
, and M
. Setting the seed initializes the state
.
Some choices of A
, B
, and M
will not achieve full cycle (relative to the modulus M
), in which case the LCG can produce two or more non-overlapping subsequences. For example, for A = 3
, B = 0
, and M = 11
you'll find yourself on one of two non-overlapping subcycles depending on your seed value.
Seeding with 1 will produce the following sequence:
3,9,5,4,1,3,9,5,4,1,3,9...
and seeding with 2 will produce:
6,7,10,8,2,6,7,10,8,2,6,7...
Other choices of the coefficients can attain full cycle. in either case the seed value corresponds to picking an entry point to a cycle or subcycle.
For other classes of generators which maintain a larger state space and collapse the state to produce each reported value, you can get repeats of individual values without repeating the identical sequence until you have enumerated the entire (not visible) state space. That's how a generator such as Mersenne Twister achieves cycle lengths such as 219937-1. Different (very large) states can collapse down to the same 32 or 64 bit quantity for an individual observation, but will lead to entirely different states being calculated (and collapsed) for the next value, so you will see repeats of individual values without seeing a repeat of the sequence of values.