You can make a global variable called "Last_generated_number" and each time you generate a number you store it here.
Then you can do a check:
random(number) = Last_generated_number
Then as long the random(number) = Last_generated_number it will make a new roll.
Then when its not Equal to the "last_generated_number" it will continue and you can use it. Then you store the new number in the "last_generated_number" variable, so it will be used for the check next time.
If you dont used negative numbers. You can just put "Last_generated_number" to -1 as default from the beginning, so it will never match the first generated number.