# How many numbers from 0 to 99999 contain the digits 2, 5 and 8?

I have this problem:

How many integers between 0 and 99999 contain the digits 2, 5 and 8?

I've tried a lot, but I don't know how resolve it.

P.S. The solution should be 4350.

Consider the alternative question: How many numbers in that range Do Not contain at least one of $$2,5,8$$?

The number where we don't care is $$10^5$$

The number which do not contain $$2$$ is $$9^5$$. Similarly so for the number which do not contain $$5$$ as well as the number which do not contain $$8$$.

The number which do not contain $$2$$ as well as simultaneously not containing $$5$$ is $$8^5$$, etc...

Apply inclusion-exclusion and get a total number of numbers which do not contain at least one of $$2,5,8$$.

$$10^5 - 3\cdot 9^5 + 3\cdot 8^5 - 7^5=4350$$

• Thank you so much, I tried a similar procedure, maybe I made a calculing mistake. – rik99 Feb 15 at 23:09

Consider the cases, where $$*$$ is a digit different from $$2,5,8$$:

1) $$258** \Rightarrow P(5,3)\cdot 7^2=2940$$.

2) $$2258*,2558*,2588* \Rightarrow 3\cdot \frac{P(5,4)}{2!}\cdot 7=1260.$$

3) $$22258,25558,25888 \Rightarrow 3\cdot \frac{P(5,5)}{3!}=60.$$

4) $$22558,22588,25588 \Rightarrow 3\cdot \frac{P(5,5)}{2!\cdot 2!}=90.$$

Hence: $$N=2940+1260+60+90=4350$$.