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.
I just noticed there is a way to use the RNG given to produce random bitstream with 100% efficiency.
If the output is '1' then add '0' to the bitstream
If the output is '2' then add '10' to the bitstream
If the output is '3' then add '110' to the bitstream
If the output is '4' then add '1110' to the bitstream