There's no formula for this problem.
I had to baby-talk my way through it.
In numbering the pages of a book, a printer used 3289 digits.
How many pages were in the book, assuming
that the first page in the book was number 1?
Hence: . digits were used
. . in the first 100 four-digit numbers.
. . . .
Therefore, the book had 1099 pages.