All of them are correct. You need to verify that the probability of getting each of the numbers from 0 to 7 are same.
In the example given by Gene, here is the explanation below: rand04() rand04() 5*rand04() Sum Sum/3 0 0 0 0 0 1 0 0 1 0 2 0 0 2 0 3 0 0 3 1 4 0 0 4 1 0 1 5 5 1 1 1 5 6 2 2 1 5 7 2 3 1 5 8 2 4 1 5 9 3 0 2 10 10 3 1 2 10 11 3 2 2 10 12 4 3 2 10 13 4 4 2 10 14 4 0 3 15 15 5 1 3 15 16 5 2 3 15 17 5 3 3 15 18 6 4 3 15 19 6 0 4 20 20 6 1 4 20 21 7 2 4 20 22 7 3 4 20 23 7 4 4 20 24 8 As you can see, each of the numbers from 0 to 7 can come 3 times hence they have equal probability. In the other approach in the link I put, the user has tried to use a number system to the base 2. On Sep 13, 5:21 pm, Krunal Modi <krunalam...@gmail.com> wrote: > So finally which answer is correct ? > There are many answers and I'm doubtful abt there correctness !! -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.