Celeb Glow
updates | April 17, 2026

Whats the probability of a random 6digit number recurring

$\begingroup$

Im creating a function that creates a random 6 digit number. I want to use it as a unique key in a table. So my question is what the probability of one of the numbers recurring if i call the function max 14 times. I was thinking that i could have an if and every time check but if the probability is low enough i would be able to save that processing power/time.

$\endgroup$ 3

1 Answer

$\begingroup$

This is a step in the birthday problem. The first number cannot be a duplicate. The second has $\frac {99\ 999}{100\ 000}$ chance of not being a duplicate. Assuming the second is not a duplicate, the third has $\frac {99\ 998}{100\ 000}$ chance of not being a duplicate and so on.

The overall chance of no duplicate is$$\frac{99\ 999!}{100\ 000^{13}\cdot 99\ 986!}\approx 0.999$$ so you have about $1$ chance in a thousand of a duplicate. Essentially you have $\frac 12 \cdot 14 \cdot 13=91$ pairs, each of which will match with probability $\frac 1{100\ 000}$

$\endgroup$ 1

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy