import java.util.*;

/****
 *
 * Class RandomGen generates a sequence of pseudo-random numbers to be used in
 * Assignment 2 testing.
 *
 * @author Gene Fisher (gfisher@calpoly.edu)
 * @version 23apr01
 *
 */

class RandomGen {

    /**
     * Generate a print a pseudo-random sequence of numbers beteen 0 and
     * args[0].  Output the sequence to stdout If args[0] is null, output a
     * message and do nothing.
     */
    public static void main(String[] args) {
	int number;				// Number of nubers to generate
        int i, rand;                            // Loop index
        int checks[];				// Numbers check list
        
	/*
	 * Get the command line arg, if any.
	 */
	if (args.length == 0) {
	    System.out.println("\nUsage: java RandomGen number\n");
	    System.exit(1);
	}
	number = Integer.parseInt(args[0]);

        /*
         * Fill the checks array with -1.
         */
	checks = new int[number];
        Arrays.fill(checks, -1);

        /*
         * Loop to generate the covering list of randoms betwee 0 and number.
         */
        for (i = 0; i < number; ) {

	    /*
	     * Generate a random number between 0 and 499.
	     */
	    rand = (int) (Math.random() * number);

	    /*
	     * Check if it hasn't already been generated.  If it hasn't, print
	     * it out and increment the loop counter.  Otherwise continue the
	     * loop without incrementing the loop counter.  In either case,
	     * increment the checks list for the generated number.
	     */
	    if (checks[rand] == -1) {
		System.out.print(rand + " ");
		i++;
	    }
	    checks[rand]++;

        }

        System.out.println();

	/*
	 * Uncomment this code if you're curious about how many tries it takes
	 * to get a covering sequence.
	 *

	for (i = 0; i < number; i++) {
	    System.out.print(checks[i] + " ");
	}
        System.out.println();

	 *
	 */

    }
}