int rand7() { int result; do { result = (rand5() + 5*rand5()-3) / 3; } while(result > 7); return result; }
On Jul 28, 8:08 am, arpit agrawal <reallygeni...@gmail.com> wrote: > Write a method to generate a random number between 1 and 7, given a method > that generates a random number between 1 and 5. The distribution between > each of the numbers must be uniform -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algogeeks@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.