# What is the possibility that at least one digit will not show up in a 20-digit “code”?

A "code" is composed of 20 digits (numbers from 0 to 9), and we want to choose a number randomly. What is the possibility that at least one digit will not show up in the code?

What I did:
We have $10^{20}$ possibilities. Now, I want to choose 9 numbers out of the ten, and choose them randomly, so the possibility is:

$\frac{10\cdot9^{20}}{10^{20}} = \frac{9^{20}}{10^{19}}$

But when I put this in the calculator, I get $1.25\dots$ I thought maybe I need a more precise calculator, but even calculators I found in google returns the same answer.

The possibility isn't supposed to be above 1. What is the problem here?

• You're counting a lot of things twice. For example, you are counting the number 11111111111111111111 as "no twos", "no threes", "no fours" and so on. – 5xum Dec 7 '17 at 11:32
• Probability of a number not being $n$ is $9\over10$. Possibility in a 20-digit sequence is $\left({9\over10}\right)^{20}=0.12157...$ – MalayTheDynamo Dec 7 '17 at 11:33
• It's not your calculator. $9^{20} = 1.215\ldots \times 10^{19} > 10^{19}$. – Eric Towers Dec 7 '17 at 15:07
• This seems like a variant of the coupon collector's problem. – Necreaux Dec 7 '17 at 16:26

For any given digit, the probability the "code" does not contain that digit is indeed $(9/10)^{20}$. But computing the probability that any one of the ten digits is missing requires the inclusion/exclusion principle.

• Add $10×(9/10)^{20}$, like you did, for the probability that one digit is missing.
• Subtract $45×(8/10)^{20}$ for the probability that two digits are missing. 45 is the number of ways to choose two digits to omit.
• Add $120×(7/10)^{20}$ for the probability that three digits are missing. Again, 120 is the number of ways to omit three digits.
• Continue until adding $10×(1/10)^{20}$ for the probability that nine digits are missing.

The final, correct answer is $0.785262\dots$

• Doesn't the wording "..... a $certain$ digit will not show up ..." imply that a particular digit doesn't show up irrespective of other digits being present or absent ? – true blue anil Dec 7 '17 at 12:02
• @trueblueanil Meaning clarified. – Parcly Taxel Dec 7 '17 at 12:03
• Was that clarified by OP ?? – true blue anil Dec 7 '17 at 12:09
• I don't think it is right to edit OP's $question$. We can ask for clarifications, or mention that it is our interpretation. – true blue anil Dec 7 '17 at 12:12
• Well the answer was actually "a certain", but I think you answered for both "at least" and "a certain". So I got the other one for a bonus. Thanks :) – sheldonzy Dec 7 '17 at 12:18