Interesting question with a mathmatically simple explanation and a not so good way of stopping it. You see computers actually generate not-so-random numbers. This meaning the numbers generated are random to a certain extent. This is why they are called pseudo-random generators. Now there is really no concreate way to fix this as most random things aren't. The only way that might
help is to make an if statment to check to see if the number is equal to a previous number and if it is then make another number. However it is still possible that you will get the same number.
Does that make sense?