There is an inefficient method you could use, to do it...
for every number you generate, you add it to an array list,
and everytime you generate a number, you traverse through the array and compare it with the new generated number, if the number is in the array, the generate number function will be invoked again, until a new number is generated.