How many such numbers in 5-digit decimal expansion such that: (1) 3rd digit is 7 and digit 5 there is neither time or (2) there is no number more than once. My solution: Let a set $A$ is a set of numbers satisfying (1), Let a set $B$ is a set of numbers satisfying (2) Let's calculate $$| A | = 8 \cdot 9 \cdot 9 \cdot 9$$ And now: $$| B | = 9 \cdot 8 \cdot 7 \cdot 6 \cdot 5$$ Now, if these numbers in $A$ that satisfy $B$, de facto: $$| A \cap B | = 8 \cdot 8 \cdot 7 \cdot 6$$ Thus, in principle, inclusions and exclusions: $$| A \cup B | = 9 \cdot 8^3 + 9 \cdot 8 \cdot 7 \cdot 6 \cdot 5 -8 \cdot 8 \cdot 7 \cdot 6 = 17040$$ OK?

• Can the first digit be $0$? – bof Nov 18 '14 at 10:40
• Please explain how you got $|B|=9\cdot8\cdot7\cdot6\cdot5$ instead of $9\cdot9\cdot8\cdot7\cdot6$. – bof Nov 18 '14 at 10:42
• How did $8\cdot9\cdot9\cdot9$ turn into $9\cdot8^3$? – bof Nov 18 '14 at 10:45
• In $A\cap B$ there are $7$ choices for the first digit, since it can't be 0, 5, or 7. Then there are $7$ choices for the second digit, since it can't be 5 or 7 or repeat the first digit. – bof Nov 18 '14 at 11:21
• I think you got it now. – bof Nov 18 '14 at 11:30

As noted in the comments, there are three errors in the calculation.

1. For $|B|$, the choice of the non-zero first digit still leaves $9$ digits to choose from, so $|B|=9\cdot9\cdot8\cdot7\cdot6$.

2. For $|A\cap B|$ we have to avoid both $5$ and $7$, and again $0$ in the first digit, which leaves $7\cdot7\cdot6\cdot5$ choices.

3. In the last equation you wrote $9\cdot8^3$ instead of $8\cdot9^3$.

So the correct total is

$$|A\cup B|=8\cdot9^3+9\cdot9\cdot8\cdot7\cdot6-7\cdot7\cdot6\cdot5=31578\;.$$