Tyra writes consecutive positive integers on a whiteboard starting with the integer \(1\). However, when she writes a number that is a multiple of \(9\), or contains the digit \(9\), Juliana immediately erases it. If they continue this for a long time, what is the 400th number that Juliana will erase?
Note: In solving this problem, it may be helpful to use the fact that a number is divisible by \(9\) exactly when the sum of its digits is divisible by \(9\). For example, the number \(214\,578\) is divisible by \(9\) since \(2+1+4+5+7+8 = 27\), which is divisible by \(9\). In fact, \(214\,578=9 \times 23\,842.\)
We first consider the integers between \(1\) and \(999\), inclusive. Since \(999 = 111 \times 9\), there are \(111\) multiples of \(9\) between \(1\) and \(999\).
Now let’s figure out how many of the integers from \(1\) to \(999\) contain the digit \(9\). The integers from \(1\) to \(99\) that contain the digit \(9\) are \(9,~19, \ldots, 79,~ 89\) as well as \(90,~ 91, \ldots, 97~ , 98,~ 99\). Thus, there are \(19\) positive integers from \(1\) to \(99\) that contain the digit \(9\). Since there are \(19\) integers from \(1\) to \(99\) that contain the digit \(9\), it follows that there are \(19 \times 9 = 171\) integers from \(1\) to \(899\) that contain the digit \(9\).
Between \(900\) and \(999\), every integer contains the digit \(9\). Thus, there are \(100\) numbers that contain the digit \(9\). Thus, in total, \(171+100 = 271\) of the integers from \(1\) to \(999\) contain the digit \(9\).
However, some of the integers that contain the digit \(9\) are also multiples of \(9\), so were counted twice. To determine how many of these such numbers there are, we use the fact that a number is divisible by \(9\) exactly when the sum of its digits is divisible by \(9\).
The only one-digit number that contains the digit \(9\) and is also a multiple of \(9\) is \(9\) itself.
The only two-digit numbers that contain the digit \(9\) and are also multiples of \(9\) are \(90\) and \(99\).
To find the three-digit numbers that contain the digit \(9\) and are also multiples of \(9\), we will look at their digit sum.
Case 1: Three digit-numbers with a digit sum of
\(9\):
The only possibility is \(900\). Thus,
there is \(1\) number.
Case 2: Three digit-numbers with a digit sum of \(18\):
If two of the digits are \(9\), then the other digit must be \(0\). The only possibilities are \(909\) and \(990\). Thus, there are \(2\) numbers.
If only one of the digits is \(9\), then the other two digits must add to \(9\). The possible digits are \(9,~4,~5\), or \(9,~3,~6\), or \(9,~2,~7\), or \(9,~8,~1\). For each of these sets of digits, there are \(3\) choices for the hundreds digit. Once the hundreds digit is chosen, there are \(2\) choices for the tens digit, and then the remaining digit must be the ones digit. Thus, there are \(3 \times 2=6\) possible three-digit numbers for each set of digits. Since there are \(4\) sets of digits, then there are \(4 \times 6 = 24\) possible numbers.
Case 3: Three digit-numbers with a digit sum of
\(27\):
The only possibility is \(999\). Thus,
there is \(1\) number.
Therefore, there are \(1+2+24+1=28\) three-digit numbers from \(1\) to \(999\) that contain the digit \(9\), and are also multiples of \(9\).
Thus, there are \(1+2+28=31\) integers from \(1\) to \(999\) that contain the digit \(9\), and are also multiples of \(9\). It follows that Juliana erases \(111+271-31=351\) of the numbers from \(1\) to \(999\) from the whiteboard. Since we are looking for the 400th number that Juliana erases, we need to keep going.
Next, we consider the integers between \(1000\) and \(1099\), inclusive. Since \(1099=(122 \times 9)+1\), there are \(122\) multiples of \(9\) between \(1\) and \(1099\). Since there are \(111\) multiples of \(9\) between \(1\) and \(999\), it follows that there are \(122-111=11\) multiples of \(9\) between \(1000\) and \(1099\). The integers between \(1000\) and \(1099\) that contain the digit \(9\) are \(1009,~1019, \ldots, 1079,~ 1089\) as well as \(1090,~ 1091, \ldots, 1097~ , 1098,~ 1099\). Thus, there are \(19\) integers from \(1000\) to \(1099\) that contain the digit \(9\). Of these, the only integers that are also multiples of \(9\) are \(1089\) and \(1098\). Thus, Juliana erases \(11+19-2=28\) of the numbers from \(1000\) to \(1099\) from the whiteboard. In total, she has now erased \(351+28=379\) numbers.
Next, we consider the integers between \(1100\) and \(1189\), inclusive. Since \(1189=(132 \times 9) +1\), there are \(132\) multiples of \(9\) between \(1\) and \(1189\). Since there are \(122\) multiples of \(9\) between \(1\) and \(1099\), it follows that there are \(132-122=10\) multiples of \(9\) between \(1100\) and \(1189\). The integers between \(1100\) and \(1189\) that contain the digit \(9\) are \(1109,~1119,\dots,1179,~1189\). Thus there are \(9\) integers from \(1100\) to \(1189\) that contain the digit \(9\). The only one of these that is also a multiple of \(9\) is \(1179\). Thus, Juliana erases \(10+9-1=18\) of the numbers from \(1100\) to \(1189\) from the whiteboard. In total, she has now erased \(379+18=397\) numbers.
The next three numbers that Juliana will erase are \(1190,~1191,\) and \(1192\). Thus, the 400th number that Juliana erases is \(1192\).