given a function that returns a random number between 1-5, how would you use this to construct a function that returns a random number between 1-7
Anonymous
Reformulate as using a function returning a number between 0 and 4 to get a number between 0 and 6. Compute x = rnd() * 5 + rnd(). That's a uniform number between 0 and 24. If the number is greater than 20, throw x away and recompute it. The result is x % 7.
Check out your Company Bowl for anonymous work chats.