NEW HERE? USE "AFORUM20" TO GET GET 20 % OFF CLAIM OFFER

UK: +44 748 007-0908 USA: +1 917 810-5386
My Orders
Register
Order Now

A Test of Probability

  Given a function called rand5() which returns a random number between 1 and 5 (inclusive), write a function called rand7() which returns a random number between 1 and 7. Be careful, the knee-jerk reaction is to call rand5() twice and add up the results to extend the range of rand5(). Do not go down this path since the probabilities are not even for a given output of rand5() + rand5(). The key here is to maintain fair probability at each step of the solution.