Combinatorics question - 5 digit number.

ok so the question is: "How many five digit natural numbers contain the digits $0$ and $3$ (each on of them) at least once.

So I think I have an answer, but not sure if it's right:

I take all the possibilities for forming a five-digit number $9\times10^4$ and subtracting whole numbers that not contain $0$ or $3\times8^5$

so my answer is : $9\times10^4-8^5$.

Is it right?

thanks.

• No. If you eliminate only the number having neither $0$ nor $3$, you still have the numbers containing a $0$ or a $3$. But you only want the numbers having both digits. Additionally, you should clear, whether the first digit is allowed to be $0$. – Peter Apr 7 '16 at 12:30
• Peter you're right....so how can I do it? – Tomer Uzan Apr 7 '16 at 12:33
• Just determine, how many numbers contain a $0$ and not a $3$ and vice versa. To get this, start with all numbers containing a $0$ and eliminate those having a $3$ (and vice versa) – Peter Apr 7 '16 at 12:35
• Another way : Take the pairs $a-b$ with positive integers and sum not exceeding $5$. These are $1-2$ , $1-3$ , $1-4$ , $2-1$ , $2-2$ , $2-3$ , $3-1$ , $3-2$ , $4-1$ and count the numbers having $a$ zeros and $b$ threes. – Peter Apr 7 '16 at 12:38
• Peter, by the way is it possible to do : 1*1*10^3? . that will make sure I will take 0 and 3. after that I can any number I want(10^3) – Tomer Uzan Apr 7 '16 at 12:50

Let $X$ be the set of all 5 digit numbers, $Z$ be the set of all 5 digit numbers without a 0, $T$ be the set of all 5 digit numbers without a 3, $B$ be the set of all 5 digit numbers without a 0 or a 3.

The idea is to take $|X|-|Z|-|T|+|B|$. Adding back the $|B|$ corrects for the fact that these numbers were eliminated twice.

So $9\cdot 10^4-9^5-8\cdot9^4+8^5=11231$

• But in Z and T you have numbers multiple times, for example: the number 12789 not contain 3 and not contain 0 so you subtracting the same number twice – Tomer Uzan Apr 7 '16 at 13:05
• almagest started with all numbers ($0$ not the first digit), subtracted the numbers not having a $0$ and the numbers not having a $3$ , then he added the numbers having neither $0$ nor $3$ because they were elminiated twice. – Peter Apr 7 '16 at 13:07
• 12789 appears in X, Z, T and B. So you end up not counting it. – almagest Apr 7 '16 at 13:09
• right. thank you both ! :) – Tomer Uzan Apr 7 '16 at 13:11
• You can interprete the formula as $9\cdot10^4-(9^5+8\cdot9^4-8^5)$, if this helps. In this case, the number having neither $0$ nor $3$ are subtracted. – Peter Apr 7 '16 at 13:12

In the case, $0$ is allowed as first digit, you calculate $$10^5-9^5-9^5+8^5=14670$$