T
tyrandor3
reference
http://java.sun.com/javase/6/docs/api/java/util/Random.html#nextInt(int)
do {
bits = next(31);
val = bits % n;
} while (bits - val + (n-1) < 0);
big problem
bits>=0
n>0
n<=bits
therefore
0<=bits%n<bits
therefore bits-bits%n > 0
therefore bits-bits%n+n-1 > 0
therefore bits-bits+n-1<0 is always false?
So how can this loop ever iterate more than once as the documentation
says it can.
http://java.sun.com/javase/6/docs/api/java/util/Random.html#nextInt(int)
do {
bits = next(31);
val = bits % n;
} while (bits - val + (n-1) < 0);
big problem
bits>=0
n>0
n<=bits
therefore
0<=bits%n<bits
therefore bits-bits%n > 0
therefore bits-bits%n+n-1 > 0
therefore bits-bits+n-1<0 is always false?
So how can this loop ever iterate more than once as the documentation
says it can.