Solution Verification: How many positive integers less than $1000$ have at least one digit that is a $9$?
Here's how I solved this:
1) No restrictions: $[1, 999]$ = $999$ numbers
2) Violation (no $9$s): there are $9$ digit choices for the first, $9$ for the second, and $9$ for the third because we exclude the number $9$ itself from the range $[0, 10]$ = $729$ such numbers
3) Condition enabled: $999$ - $729$ = $270$.
Something feels off, though. Is this solution correct? Sorry if this seems trivial.
Edit: I suspect I may encounter problems for numbers where the first two digits are $0$s--did I overcount?
$\endgroup$3 Answers
$\begingroup$You can salvage your approach.
A positive integer less than $1000$ has a unique representation as a $3$-digit number padded with leading zeros, if needed.
To avoid a digit of $9$, you have $9$ choices for each of the $3$ digits, but you don't want all zeros, so the excluded set has count $9^3 - 1 = 728$.
Hence the count you want is $999 - 728 = 271$.
$\endgroup$ $\begingroup$To consider the complement is a fine idea, but better to partition $[1,999]$ as $$ I_1 \cup I_2 \cup I_3 = [1,9]\cup[10,99]\cup[100,999] $$ in such a way that every element of $I_k$ has exactly $k$ digits. Let us call bad a number with no $9$ in its decimal representation. There are $8$ bad numbers in $I_1$, $8\cdot 9=72$ bad numbers in $I_2$ and $8\cdot 9\cdot 9$ bad numbers in $I_3$, hence a total of $8(1+9+9^2)=728$ bad numbers in $[1,999]$, contra $999-728=\color{red}{271}$ numbers with at least one $9$ in their decimal representation.
$\endgroup$ 6 $\begingroup$You can build an argument as follows. There is exactly one number less then 10. What about less than a 100? There are 19 of them: 9, 19, ..., 99 and 90, 91, ..., 98. What about less than 1000? As it is already mentioned, there are 271. In general, let $N_k$ be the number of numbers less than $10^k$ that contain the digit 9. Then $$N_{k+1} = 9N_k + 10^k = 10^k - 9^k.$$
Interestingly enough, we have $$\frac{N_{k+1}}{10^k} = \frac{10^k - 9^k}{10^k} = 1- \left(\frac{9}{10}\right)^k.$$ Since the above limit goes to 1 as $k\rightarrow \infty$, almost all the numbers contain the digit 9, or any digit for that matter.
$\endgroup$More in general
"Zoraya ter Beek, age 29, just died by assisted suicide in the Netherlands. She was physically healthy, but psychologically depressed. It's an abomination that an entire society would actively facilitate, even encourage, someone ending their own life because they had no hope. Th…"