I get 2304 by running it. I don't think Random itself is intended to be
cryptographically secure or anything. It's open source and its seeding is
deterministic. The result from similar seeds need not be apparently random.

If all this matters use SecureRandom or MersenneTwisterRNG.
On 20 Feb 2011 04:52, "Lance Norskog" <[email protected]> wrote:
> What does this program print?
>
>
> package hack;
>
> import java.util.Random;
>
> public class JDKRandomThreatOrMenace {
>
> public static void main(String[] args) {
> Random rnd = new Random(0);
>
> double last = rnd.nextDouble();
> long i = 1;
> for(; i < Long.MAX_VALUE; i++) {
> rnd.setSeed(i);
> double next = rnd.nextDouble();
> if (Math.abs(next - last) > 0.2)
> break;
> }
> System.out.println(i);
> }
>
> }
>
> Your prize if you get it right? A patch would be welcome...
>

Reply via email to