exercise 3.6 pseudo-random number generator