# Probability of repeating at least 2 digits

Pin codes consist of 4 digits between 0 and 9. If a pin-code were generated by a random number generator (e.g. by 4 ten-sided dice), what is the probability that it will have at least two digits that repeat?

-
Does 1272 have two digits that repeat according to your definition, or is it only things like 1227 you're after? –  Henning Makholm Feb 3 '13 at 22:50
Sample of pin codes consisting at least 2 digits that repeat: 1494, 1444, 4444, 4499, etc. so 1272 and 1227 are both in the sample –  user60852 Feb 3 '13 at 22:52

It's easier to compute the probability of the opposite event, namely that you get four different digits.

Imagine that you choose the digits one by one by rolling a singe ten-sided die. You win if some digit appears twice. What is the chance of losing? In order to lose, all of the following must be true:

• The first digit is some digit.
• The second digit is different from the first digit, which happens with probability 9/10.
• The third digit is different from the two first ones. They are already known to be different, so this happens with probability 8/10.
• The fourth digit is different from the tree first ones, which happens with probability 7/10.

So the probability of losing is $\frac{9}{10}\cdot\frac{8}{10}\cdot\frac{7}{10}=\frac{9\cdot 8\cdot 7}{1000} = 0.504$

The chance of winning is one minus this.

-

Hint: There are $10^4$ total codes. To not duplicate, you have $10$ choices for the first number, $9$ for the second, and ???

-