+ 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.
28th Jun 2018, 8:23 AM
To Seek Glory in Battle is Glorious
To Seek Glory in Battle is Glorious - avatar
+ 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.
28th Jun 2018, 4:54 AM
Oma Falk
Oma Falk - avatar
+ 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)
28th Jun 2018, 8:27 AM
To Seek Glory in Battle is Glorious
To Seek Glory in Battle is Glorious - avatar
+ 1
something wrong with example ( application of theorem Fermat). no # 1. general idea correct. and thanks for explanation. edit: fixed. n/a
28th Jun 2018, 3:52 PM
yuri
+ 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.
28th Jun 2018, 4:13 PM
To Seek Glory in Battle is Glorious
To Seek Glory in Battle is Glorious - avatar
+ 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?
29th Jun 2018, 9:04 AM
yuri
+ 1
Thank you yuri. I was rushing into that, so I made some mistakes. Will fix it.
29th Jun 2018, 11:09 AM
To Seek Glory in Battle is Glorious
To Seek Glory in Battle is Glorious - avatar