algorithm design techniques suppose we only need to flip cointhuswe must generate (for headsor (for tailsrandomly one way to do this is to examine the system clock the clock might record time as an integer that counts the number of seconds since some starting time we could then use the lowest bit the problem is that this does not work well if sequence of random numbers is needed one second is long timeand the clock might not change at all while the program is running even if the time was recorded in units of microsecondsif the program was running by itselfthe sequence of numbers that would be generated would be far from randomsince the time between calls to the generator would be essentially identical on every program invocation we seethenthat what is really needed is sequence of random numbers these numbers should appear independent if coin is flipped and heads appearsthe next coin flip should still be equally likely to come up heads or tails the simplest method to generate random numbers is the linear congruential generatorwhich was first described by lehmer in numbers are generated satisfying xi+ axi mod to start the sequencesome value of must be given this value is known as the seed if then the sequence is far from randombut if and are correctly chosenthen any other < is equally valid if is primethen xi is never as an exampleif and then the numbers generated are notice that after numbersthe sequence repeats thusthis sequence has period of which is as large as possible (by the pigeonhole principleif is primethere are always choices of that give full period of some choices of do notif and the sequence has short period of if is chosen to be large -bit primethe period should be significantly large for most applications lehmer suggested the use of the -bit prime - , , , for this primea , is one of the many values that gives full-period generator its use has been well studied and is recommended by experts in the field we will see later that with random-number generatorstinkering usually means breakingso one is well advised to stick with this formula until told otherwise this seems like simple routine to implement generallya class variable is used to hold the current value in the sequence of ' when debugging program that uses random we will use random in place of pseudorandom in the rest of this section for instanceit seems that xi+ ( , xi mod( would somehow be even more random this illustrates how fragile these generators are [ , ( , , mod( , , so if the seed is , , the generator gets stuck in cycle of period