[Math] How many numbers between $0$ and $9999$ have either of the digits $2,5,8$ at least once – Check the answer

combinatoricsproof-verification

I'm preparing for an exam in combinatorics, and these type of question can certainly be in the exam.

I managed to solve it, but I'm unsure, and also would love to hear if there is a better way to do it (since I can't use a calculator in the exam, and this is quite calculation heavy)

What I did

numbers containing only $0,1,3,4,6,7,9$ are invalid. Let's count all the invalid ones:

Invalid numbers with 4 digits: We have $6$ options for the leftmost digit (not zero, two, five or eight), and $7$ options for the rest (because zero is allowed there) so thats $6*7*7*7=2058$

Invalid numbers with 3 digits: $6$ options for first digit, $7$ for the rest, that's $6*7*7=294$

Invalid numbers with 2 digits: $6$ for the first one, $7$ for the second one, thats $6*7=42$

Invalid numbers with a single digit: $7$ options ($0,1,3,4,6,7,9$)

Altogether: $2058+294+42+7=2401$

We have overall $2401$ invalid numbers, so $10000-2401=7599$ are valid.

Best Answer

Your answer is correct, but there is a more straightforward method you could use.

Just like you did first, let's consider the number of invalid numbers. So what we want to do is figure out how many numbers can be made using only the $7$ invalid digits. Imagine 4 slots, in which any of the $7$ digits can go. In the first slot, there can be 7 differents digits, in the second slot there can be also 7 different digits, and so on. We thus have $7\cdot 7 \cdot 7 \cdot 7$ different numbers consisting of invalid digits.

Your answer is $10000 - 7^{4}$ .

Related Question