Suppose you have a function (or a magic ball) that is capable of producing a totally random integer between 1 and 5 (inclusive).
Using this, how would you generate a random number (also an integer) between 1 and 7 (inclusive)? (Note that the for the number to be random, all integers between 1 and 7 must have an equal chance of being generated)
Assume that using your 1-5 generator is pretty time-consuming, so you want to minimize the number of times you are going to use it.
Just some thoughts .. you can only get 5^n solutions which is never divisible by 7 unless you discard some of the solutions .. in which case, it could (possibly) go on forever
My first reaction was to get a number, and then if it is 1, stop, otherwise get another number, which gives you 21 different outcomes which can be divvied up to the numbers from 1 to 7, but whatever number is assigned to the first number being 1 will have an advantage over the rest ..