BEGIN { # Initialize the seed with 5. min = 5; # In total I want to generate 5 numbers. total=7; # Maximum number is 50. max=50; srand(min); count=0; while(count < total) { rnd = int(rand() * max); if ( array[rnd] == 0 ) { count++; array[rnd]++; } } for ( i=5; i<=max; i++) { if ( array[i] ) print i; } }