/* Takes in arguments N and M (assume both positive) Prints out M numbers uniformly distributed between 1 and N */ public class RandomIntegers { public static void main(String [] args) { int N = Integer.parseInt(args[0]); int M = Integer.parseInt(args[1]); //print out M numbers between 1 and N for(int i = 0; i < M; i++) { //r is between [0,N-1] int r = (int) (Math.random() * N); //increment r by 1, gives range: [1,N] System.out.println(r+1); } } }