import java.math.*; public class TestRand { static BigInteger s = new BigInteger("12345"); static BigInteger c = new BigInteger("22695477"); static BigInteger o = new BigInteger("1"); static BigInteger a = new BigInteger("65536"); static BigInteger b = new BigInteger("16384"); static BigInteger t = new BigInteger("2").pow(30); static BigInteger x = new BigInteger("0"); public static void nextSeed() { s = s.multiply(c).add(o); } public static BigInteger randInt() { return s.divide(a).mod(b); } public static BigInteger randModInt() { return s.mod(t).divide(a).mod(b); } public static void main(String[] args) { for (int i=0; i<4; i++) nextSeed(); for (int i=0; i<6; i++) { System.out.println("Seed is: "+s); System.out.println("Seed%2^64: "+s.mod(t)); System.out.println("Number is: "+randInt()); System.out.println("Other is: "+randModInt()); System.out.println(); nextSeed(); } //System.out.println( s.divide(a).mod(b)); } }