# How many $n$-digit decimal sequences (using the digits $0 = 9$) are there in which the digits $1$, $2$ and $3$ all appear?

I feel the answer should be $nC3 \times 3! \times 10^{n-3}$.

• You are missing a couple of subtle points. Can you have leading zeros on your n digit number? i.e. is 1 considered an n-digit number by writing it 00...0001? Also, when you choose where to put the 1, 2, and 3 (your "nC3 X 3!") what happens when you have more than one 1? or more than one 2? you seem to do doing some over counting. – TravisJ Sep 30 '15 at 15:38
• @TravisJ It is an n-digit sequence not an n-digit number – pranavps Sep 30 '15 at 15:56
• @TravisJ But I got the overcounting part – pranavps Sep 30 '15 at 15:56
• Thanks. I overlooked the sequence/number distinction. – TravisJ Sep 30 '15 at 16:16

The number of $n$ digit sequences is $10^n$. The number missing $1$ is $9^n$, so we would subtract $3\cdot 9^n$ to remove the ones missing $1, 2, \text { or }3$, but now we have removed the ones missing $1$ and $2$ (or any other pair) twice so we have to add back in $3 \cdot 8^n$. Now the ones missing all of $1,2,3$ have been removed three times and added back three times, so we subtract them once more. Finally we have $10^n-3\cdot 9^n + 3 \cdot 8^n-7^n$. This is known as the inclusion-exclusion principle