previous up next print clean
Next: Schrage's method Up: GENERATING RANDOM SEQUENCES Previous: Shuffling integers

A simple shuffle

If the product of magic1 and magic2 is less than the maximum sized integer that the computer can represent, then the code is straightforward, and is listed in the Appendix as SUB1. The modulo, magic2, is the Mersenne prime (219-1), and the multiplier, magic1, is 727, which is primitive modulo magic2. These two conditions guarantee that the cycled sequence is complete (see Knuth).

Stanford Exploration Project