Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|cite|improve this question
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
up vote 2 down vote accepted

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.

share|cite|improve this answer

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

share|cite|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.