Think about Loose Coupling | |
PerlMonks |
Re^2: Check randomly generated numbers have not been used before # Math!by LanX (Saint) |
on Jun 21, 2014 at 14:30 UTC ( [id://1090774]=note: print w/replies, xml ) | Need Help?? |
> The odds of an actual collision for a 7-digit random number are so astronomically small that I quite frankly would not bother to check for it. the odds for no collision are easily calculated:
So the odds of a collision is already bigger than 50% after 3723 draws!¹ Actually there are already combinatorial formulas that avoids the loop completely. For the interested readers: Cheers Rolf (addicted to the Perl Programming Language) ¹) and bigger than 99% after 9600 draws! ²) which many of us should have encountered at school already ... :-/
In Section
Seekers of Perl Wisdom
|
|