I don't think so that probability would be exact 1/1000 .

suppose number is  ( a9 a8 a7 a6 a5 a4 a3 a2 a1 a0) where a0 is least and a9
is most significant bit then you can generate each of the bit ai using given
bit generator

but if but at a time  (a9 , a8 , a7 , a6 , a5 , a3 ) and any other bit are
set together then number would exceed given limit 1000 which we don't want .

so dave's solution generate numbers with probability 1/(2^n) where n is
ceil(log2(b-a+1)) so 1/2^10 = 1/1024

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