Hacker News new | ask | show | jobs
by quietbritishjim 2551 days ago
For ease of reference, here is the text at that link verbatim:

Choose a 2-digit number, say 23, your "seed".

Form a new 2-digit number: the 10's digit plus 6 times the units digit.

The example sequence is 23 --> 20 --> 02 --> 12 --> 13 --> 19 --> 55 --> 35 --> ...

and its period is the order of the multiplier, 6, in the group of residues relatively prime to the modulus, 10. (59 in this case).

The "random digits" are the units digits of the 2-digit numbers, ie, 3,0,2,2,3,9,5,... the sequence mod 10. The arithmetic is simple enough to carry out in your head.

This is an example of my "multiply-with-carry" random number generator, and it seems to provide quite satisfactory sequences mod 2^32 or 2^64 , particularly well suited to the way that modern CPU's do integer arithmetic.

You may choose various multipliers and moduli for examples of random selection of the types you ask about.

A description of the multiply-with-carry method is in the postscript file mwc1.ps, included in

The Marsaglia Random Number CDROM with

The DIEHARD Battery of Tests of Randomness,

available at

http://stat.fsu.edu/pub/diehard/

George Marsaglia