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(4): solution - Charlie?
When expanded to an ideal case, your algorithm approaches (log 37)/(log 2) = 5.21 calls per random number generated. My algorithm uses 4.378 calls per random number generated.