Random number generator RNG and periodic outputs

The problem with such generators is that their outputs are periodic; they will start to repeat themselves with a period that is at most \( M \). If however the parameters \( a \) and \( c \) are badly chosen, the period may be even shorter.

Consider the following example $$ \begin{equation*} N_i=(6N_{i-1}+7) \mathrm{MOD} (5), \end{equation*} $$ with a seed \( N_0=2 \). This generator produces the sequence \( 4,1,3,0,2,4,1,3,0,2,...\dots \), i.e., a sequence with period \( 5 \). However, increasing \( M \) may not guarantee a larger period as the following example shows $$ \begin{equation*} N_i=(27N_{i-1}+11) \mathrm{MOD} (54), \end{equation*} $$ which still, with \( N_0=2 \), results in \( 11,38,11,38,11,38,\dots \), a period of just \( 2 \).