[Math] How many positive integers less than 1000 are there which contain at least one 4 or at least one 9 (or both)

combinatorics

How many positive integers less than 1000 are there which contain at least one 4 or at least one 9 (or both)?

Obviously theres 100 in 400's and 900's but short of counting every other number whats the quickest way to work this out?

Best Answer

There are $8^3-1$ numbers that contain neither $4$ nor $9$. (The $-1$ is because $000$ doesn't count).

Subtract that from the total number of integers less than $1000$.


Of course, since $0$ doesn't have a $4$ or $9$ anyway, you could equally well ask about non-negative integers less than $1000$, in which case you'd just subtract $8^3$ from $10^3$, getting the same result.