A particular random number generator returns positive integer n with probability 1/(2^n). (ie '1' with probability 1/2, '2' with probability 1/4, '3' with probability 1/8, etc.)
Using this random number generator, write an algorithm which chooses a random integer from 1 to 37 with equal probability.
(In reply to
re(2): solution - Charlie? by Thalamus)
Since you are using 6 calls to RNG for each 1-64 number but throwing away 27/64 of them, the average number of calls per 1-37 number is 6*64/37= 10.4.
|
Posted by Charlie
on 2004-06-15 20:27:24 |