On Sep 19, 4:46 am, avalon <avalo...@gmail.com> wrote: > Forgive me first if i am wrong since i didn't read all the posting ... > Here is a way to sol the problem. > > n1 = random_1_5() + 0; > n2 = random_1_5() + 5; > .. > n7= random_1_5() + (7-1)*5; > > now n1 ... n7 is in range [1 ... 35] > Image we divde the range [1.. 35] into 5 parts, such as [1...7] , > [8...14] ... > > then we generat n8 = random_1_5() > we use n8 to pick a part we divided above. > so we get a range [a...b] , then we can get a number ni inside the > range, > return ni;
Unfortunately this doesn't work because the 7 element ranges might include zero or two of the random samples drawn from n1..n7. For example suppose you get n5=21, n6=29 and n8 = 4, which gives range [22-28]. There is no number in this range. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---