Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Random

Name: Anonymous 2012-02-01 5:14

You are given a function randBit() that returns {0,1}

You want to write a function randNum(start,stop) {a,b} where the function will return a number between a and b with even distribution.


The function is required to run in a guaranteed time, so you can't just use binary representation. ex) you want a number between 0 and 10, the closest bit combination is 16, so a bin representation will fail 6 out 16 times.  What is the best way to do this?

Name: Anonymous 2012-02-02 5:05

>>14
Or the fact that any number which is not a power of 2 is not a factor of 2^p for any p.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List