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
This little program should do the trick... by Erik O.)
There are some defects in the program, but the main problem is that it doesn't use the provided generator... just a note!
|
Posted by Oskar
on 2004-06-08 15:45:42 |