Calculate the sequence of pseudo-random-numbers for the following linear congruential generator

56 Views Asked by At

Given is a linear congruential generator based on following numbers: $a,c,m \in \mathbb{Z}$ with $2 \leq a < m$ and $0 \leq c < m$, and the starting value $0 \leq x_{0} < m$.

Calculate the sequence of pseudo-random-numbers $x_{1},...,x_{m}$ for the following linear congruential generator and state its period:

$$m=18, a = 7, c=7, x_{0}=5$$

This is a task from an old exam, it has many other similar sub task. I think if I understand this one, I could solve the other ones myself. But how can this be solved correctly?

I found this formula on the internet:

$$y_{i}=(ay_{i-1}+b) \text{ mod } m$$

Applying it to this task, we have(?):

$$x_{i}=(ax_{i-1}+c) \text{ mod } m$$

Insert values:

$$x_{1}=(7 \cdot x_{1-1}+7) \text{ mod } 18$$

$$x_{1}= (7 \cdot 5 +7) \text{ mod } 18$$

$$x_{1} = 6$$

I hope this is correct? And we do this how often? Till $x_{5}$ would be enough? What about the period?

Please help me, I got absolute no source solving this and I want understand it.