Mi viene chiesto di creare un generatore di numeri pseudo-casuali usando il seguente algoritmo:
The generator will generate every integer from
1toN-1exactly onceThe algorithm for
N=2^n
- Initialize an integer
Rto be equal to1every time the tabling routine is called and then on each successive call for a random number:- set
R=R*5- mask out all but the low-order
n+2bits of the product and place the result in R- set
p=R/4
Che cosa significa l'algoritmo quando dice mascherare tutto tranne i bit di basso ordine n+2 del prodotto?