# Wichmann-Hill Random Number Generator

Download: random2.bas

Size 0kb, downloads 1049.

Here's a random number generator that uses the Wichmann-Hill method. It should result in better output than the simpler Random Number Generator posted elsewhere. The disadvantage over the simple generator is that it takes up four variables instead of one: **W** is the random number returned, and **X**, **Y** and **Z** are the seeds.

Before you call the random number generator, you must set X, Y and Z to non-zero values. Afterwards, use the subroutine as follows:

GOSUB 200 LET W=W-W/n*n

This will return a number from 0 to **n**-1.

## Comments