+ 6
As an example to explain the underlying process, I'm going to summerize the "Linear Congruential Generators" or (LCGs) as the most basic mechanism to produce pseudo random number generator. LCGs do its job by using the following relationship
Xn+1 = (Xn * A + B) % M
where Xn+1 is the next random number, Xn is the current random number, A and B are two arbitrary constants, and M is the range of randomizing.
~example~
Suppose
A = 5
B = 3
M = 8
Now, let's plug these values to above formula.
X0 = 0 <- seed value
X1 = (0*5+3)â
8 = 3
X2 = (3*5+3)â
8 = 2
X3 = (2*5+3)â
8 = 5
X4 = (5*5+3)â
8 = 4
X5 = (4*5+3)â
8 = 7
X6 = (7*5+3)â
8 = 6
X7 = (6*5+3)%8 = 1
X8 = (1*5+3)%8 = 0
As you can see, after X8 the random sequence repeat itself. At best case like above, the sequence can produce M-1 (full period) different values before starts repeating.
~full period conditions~
1. B and M must be relatively prime
2. A-1 must be divisible by all prime factors of M
3. If M is a multiple of 4, then A-1 must be a multiple of 4.
+ 3
1.) If u think, it is already asked, use search.
2.) you didnt even post, in which language.
Could you please do that two thinks? After I am sure you get a good answer.
+ 3
...Continue...
In above example,
B and M have no common factors (satisfies rule 1).
A-1 is 4 and that is divisible by 2 wich is the only prime factor of 8 (satisfies rule 2).
M is divisible by 4 so A-1 wich is 4 (satisfies rule 3)
+ 1
something wrong with example ( application of theorem Fermat). no # 1. general idea correct. and thanks for explanation.
edit: fixed. n/a
+ 1
yuri
The generator is defined by recurrence relation. I didn't go through primality test which is Fermat's little theorem is all about (if you meant that). I can't see anything wrong.
+ 1
but your generator is not random at all. there us no Xk=1
if you correctly specify A , it should not be the case , should it?
+ 1
Thank you yuri.
I was rushing into that, so I made some mistakes. Will fix it.



