dimanche 31 janvier 2016

Random number generator repeating some numbers to often golang

I'm writing a lottery draw simulation program as a project. The way the game works is you need to pick the 6 numbers that are draw from the 49 to win. Your chance of winning is 1/13,983,816 because that's how many combinations of 6 in 49 there are. The demo program (google playground) generates six new numbers each time around the loop forever. Each time a new set of numbers is generated I test to see if it already exists and if it does I break out of the loop. With 13,983,816 combinations you would think it would be a long time before the same 6 numbers would repeat but, in testing it fails always before 10000 iteration. Does anyone know why this is happening?




Aucun commentaire:

Enregistrer un commentaire