I am trying to design a random number generator which generates random numbers from 0-11.But I need to design that considering I already have a random number generator which generates random number from 0-5.All the numbers from 0-11 should be generated with equal probability.
I went through this link
Now can i change the function which modulus it by 12 and recurse the function if the number surpasses 24, in the function which is defined in the link above?If not then I am not understanding what is wrong.
Alternatively I came upon this one
lets call the random number generator function f(6) which generates number 0-5.
(f(6)+f(6)+f(6))%12;
If not what alternative solution can i deduct?I need help in doing this task.Maybe I am missing something.The catch here is each number between 0-11 should have equal probability of generation.
Aucun commentaire:
Enregistrer un commentaire