
public class MyRandom {
    //(28,1013) has a period of 1013
	//(30, 1023) has a period of 10
	
	public static final int A = 30;
	public static final int M = 1023;
	
	private int seed;
	
	public MyRandom(int seed) {
		this.seed = seed;
	}
	
	//return a value from 0..1 (not including 1)
	public double nextDouble() {
		//return Math.random();
		seed = A*seed % M;
		return (double)seed/M;
	}
	
	//return an int between min and max (not including max)
	public int nextInt(int min, int max) {
		int range = max - min;
		return (int)((nextDouble()*range) + min);
	}
	
	
	public static void main(String[] args) {
		MyRandom rand = new MyRandom(13);
		
		for(int i = 0; i < 10; i++) {
			System.out.printf("%10d", rand.nextInt(0, 100));
		}
		System.out.println();

		for(int i = 0; i < 10; i++) {
			System.out.printf("%10.6f", rand.nextDouble());
		}
		System.out.println("");
		
		for(int i = 0; i < 1050; i++) {
			if(i % 50 == 0)
				System.out.println();
			System.out.printf("%2d", rand.nextInt(0, 10));
		}

	}

}
