int rand7()
{
 int x = 5*rand5() + rand5(); //enlarge the range from (0 to 5 )to 0
to 24 by multiplying with 5
if(x > 20)
return rand7() ;//recursive call
else
return x%7;//this will result in uniform distribution of number
between 0-6


}

-- 
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.

Reply via email to