News for hackers. Stuff that matters.
Re:My Job Interview at Google by ig1 on Monday November 24, 2008 @06:02PM (#375589)
Generate two random numbers with your rand5 function, let them be the two digits of your base 5 number. Each number from 0-24 has a 1/25 chance of being picked.

If the number is greater than 6 throw it away and repeat, otherwise you have your random number.

Re:My Job Interview at Google by llimllib on Monday November 24, 2008 @09:22PM (#375866)
Works, but not as efficient as possible. Look at patio11's solution; you only need to throw it away and repeat if it's >= 21. Otherwise you can just take n mod 7.