## Boring Book

After finishing a very boring book, Fred notices that the page numbers contained exactly $29$ zeros and exactly $137$ ones. The book started with page $1$. How many pages were in the book?
Source: NCTM Mathematics Teacher, December 2005

SOLUTION
We arrange the numbers in rows of $10$ numbers as follows
$1,2,3,\cdots,9$
$10,11,12,13,\cdots,19$
$20,21,22,23,\cdots,29$
$30,31,32,33,\cdots,39$
$\cdots$
$90,91,92,93,\cdots,99$
$100,101,102,103,\cdots,109$
$110,111,112,113,\cdots,119$
$\cdots$
$180,181,182,183,\cdots,189$
$190,191,192,193,\cdots,199$
Each row starting from row $10$ contains $1$ zero except row $100$ which contains $11$ zeros. The number of rows containing $1$ zero is $18$. The total number of zeros from page $1$ to page $199$ is
$18\times 1+1\times 11=29$
Thus, the book has at most $199$ pages.
On the other hand, $9$ rows have $1$ one, $10$ rows have $11$ ones, while row $110$ has $21$ ones. The total number of ones from page $1$ to page $199$ is
$9\times 1+10\times 11+1\times 21=140$
Since the book has $137$ ones, the last page must be $196$. The book has $196$ pages.

Answer: $196$