A librarian has to put stamps on the pages of a book. He puts exactly as many stamps as there are '1' in the number on the page ( one stamp on pages 1, 10, 12-19, 21, 31 , ..., two stamps on pages 11,101,121, 131, ... no stamps on pages 2-9, 20, 22-30, 32-40, ... )
The librarian wonders if it is possible that, at the end of this process, the number of stamps is greater or equal to the number of pages.
This clearly happens if the "book" has exactly one page. Can it ever happen again? if so, what is (very roughly) the smallest number of pages required for this to happen?
Assumptions: the pages of the book are numbered 1, 2, 3, 4, ... It does not start at an arbitrary number and the only pages which count are those which are numbered (e.g. ignore front and back cover)
This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try
refreshing the page, (b) enabling javascript if it is disabled on your browser and,
finally, (c)
loading the
non-javascript version of this page
. We're sorry about the hassle.
Let f ( n ) be the function for the number of stamps in a book with n pages. Note that this function is non-decreasing.
Compute the values of f ( 1 0 k − 1 ) as follows: there are 1 0 k numbers from 0 to 1 0 k − 1 . Write each of these numbers with k digits (adding 0 if necessary). As an example for k = 4 and the number 10, write 0010. Note that when the number are so written, all digits (from 0 to 9) appear equally often. Each number has k digits and there are 1 0 k numbers (including 0). Hence there are in total k 1 0 k digits. Since all of the 10 digit have the same relative frequency (that is 1 0 1 ) one gets that f ( 1 0 k − 1 ) = 1 0 1 k 1 0 k = k 1 0 k − 1 .
The first thing to note is that it will happen that f ( n ) ≥ n : f ( 1 0 1 0 − 1 ) = 1 0 ⋅ 1 0 1 0 − 1 = 1 0 1 0 .
To check when this will happen, one can compute the value of f iteratively. For some n = ∑ i = 0 d a i 1 0 i (where a i ∈ { 0 , 1 , 2 … , 9 } and a d = 0 ) call a d the leading digit, r = ∑ i = 0 d − 1 a i 1 0 i the rest and d is the number of digits minus one. There are two cases to distinguish: if a d = 1 , then f ( n ) = r + 1 + f ( r ) + f ( 1 0 d − 1 ) . Otherwise f ( n ) = 1 0 d + f ( r ) + a d ⋅ f ( 1 0 d − 1 ) .
Since the question only asks for a rough estimate, let us check when is f ( n ) ≥ n for n of the form n = 2 ⋅ 1 0 k : f ( 2 ⋅ 1 0 k ) = 1 0 k + 2 ⋅ k ⋅ 1 0 k − 1 This is ≥ 2 ⋅ 1 0 k for any k ≥ 5 . So the answer is very probably hundred of thousands.
To be certain, let n be the largest integer so that f ( i ) < i for all 1 < i < n . Then f ( a d 1 0 d + r ) = 1 0 d + f ( r ) + a d f ( 1 0 d − 1 ) ≤ 1 0 d + r + a d f ( 1 0 d − 1 ) = 1 0 d + r + a d d 1 0 d − 1 = r + ( 1 0 + a d d ) 1 0 d − 1 Now if f ( a d 1 0 d + r ) ≥ a d 1 0 d + r then a d 1 0 d + r ≤ f ( a d 1 0 d + r ) ≤ r + ( 1 0 + a d d ) 1 0 d − 1 ⟺ 1 0 a d ≤ 1 0 + a d d ⟺ a d ≤ 1 0 − d 1 0 . If d < 5 then a d < 2 (so a d = 1 ). However, if f ( n ) ≥ n at a n with leading digit =1 then f ( 2 ⋅ 1 0 d ) ≥ 2 ⋅ 1 0 d (because f increases at least linearly when the leading digit is 1). By the previous computation, d ≥ 5 which contradicts d < 5 .
So the first n so that f ( n ) ≥ n is somewhere between 100 000 and 200 000. Note that actually f ( 2 ⋅ 1 0 5 ) = 2 ⋅ 1 0 5 . With a computer program (for the range 100000 to 200000), one can check that the first time f ( n ) ≥ n (in fact =) is at n = 1 9 9 9 8 1 .