We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
For those who are not using Java to solve this problem, the following is some related source code from the java.util.Random library. ;)
publicsynchronizedvoidsetSeed(longseed){this.seed=(seed^0x5DEECE66DL)&((1L<<48)-1);haveNextNextGaussian=false;}protectedsynchronizedintnext(intbits){seed=(seed*0x5DEECE66DL+0xBL)&((1L<<48)-1);return(int)(seed>>>(48-bits));}publicintnextInt(intn){if(n<=0)thrownewIllegalArgumentException("n must be positive");if((n&-n)==n)// i.e., n is a power of 2return(int)((n*(long)next(31))>>31);intbits,val;do{bits=next(31);val=bits%n;}while(bits-val+(n-1)<0);returnval;}
PRNG Sequence Guessing
You are viewing a single comment's thread. Return to all comments →
For those who are not using Java to solve this problem, the following is some related source code from the java.util.Random library. ;)