Conan the librarian

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)

in the order of magnitude of 1 0 8 10^{8} pages in the order of magnitude of 1 0 10 10^{10} pages in the order of a hundred thousand pages This cannot happen in the order of a thousand pages

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.

1 solution

Antoine G
Sep 23, 2017

Let f ( n ) f(n) be the function for the number of stamps in a book with n n pages. Note that this function is non-decreasing.

Compute the values of f ( 1 0 k 1 ) f( 10^k -1) as follows: there are 1 0 k 10^k numbers from 0 to 1 0 k 1 10^k -1 . Write each of these numbers with k k digits (adding 0 if necessary). As an example for k = 4 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 k digits and there are 1 0 k 10^k numbers (including 0). Hence there are in total k 1 0 k k 10^k digits. Since all of the 10 digit have the same relative frequency (that is 1 10 \frac{1}{10} ) one gets that f ( 1 0 k 1 ) = 1 10 k 1 0 k = k 1 0 k 1 f(10^k-1) = \frac{1}{10} k 10^k = k 10^{k-1} .

The first thing to note is that it will happen that f ( n ) n f(n) \geq n : f ( 1 0 10 1 ) = 10 1 0 10 1 = 1 0 10 f(10^{10}-1) = 10 \cdot 10^{10-1} = 10^{10} .

To check when this will happen, one can compute the value of f f iteratively. For some n = i = 0 d a i 1 0 i n = \sum_{i=0}^d a_i 10^i (where a i { 0 , 1 , 2 , 9 } a_i \in \lbrace 0,1,2 \ldots, 9 \rbrace and a d 0 a_d \neq 0 ) call a d a_d the leading digit, r = i = 0 d 1 a i 1 0 i r = \sum_{i=0}^{d-1} a_i 10^i the rest and d d is the number of digits minus one. There are two cases to distinguish: if a d = 1 a_d = 1 , then f ( n ) = r + 1 + f ( r ) + f ( 1 0 d 1 ) f(n) = r+1+f(r)+f( 10^d -1) . Otherwise f ( n ) = 1 0 d + f ( r ) + a d f ( 1 0 d 1 ) f(n) = 10^d + f(r)+ a_d \cdot f(10^d-1) .

Since the question only asks for a rough estimate, let us check when is f ( n ) n f(n) \geq n for n n of the form n = 2 1 0 k n = 2 \cdot 10^k : f ( 2 1 0 k ) = 1 0 k + 2 k 1 0 k 1 f(2 \cdot 10^k) = 10^k + 2 \cdot k \cdot 10^{k-1} This is 2 1 0 k \geq 2 \cdot 10^k for any k 5 k \geq 5 . So the answer is very probably hundred of thousands.

To be certain, let n n be the largest integer so that f ( i ) < i f(i) < i for all 1 < i < n 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 + ( 10 + a d d ) 1 0 d 1 f(a_d 10^d + r ) = 10^d + f(r)+ a_d f(10^d-1) \leq 10^d + r + a_d f(10^d-1) = 10^d + r + a_d d 10^{d-1} = r + (10+a_d d) 10^{d-1} Now if f ( a d 1 0 d + r ) a d 1 0 d + r f(a_d 10^d + r ) \geq a_d 10^d + r then a d 1 0 d + r f ( a d 1 0 d + r ) r + ( 10 + a d d ) 1 0 d 1 10 a d 10 + a d d a d 10 10 d a_d 10^d + r \leq f(a_d 10^d + r ) \leq r + (10+ a_d d) 10^{d-1} \iff 10 a_d \leq 10 + a_d d \iff a_d \leq \frac{ 10 }{10-d} . If d < 5 d < 5 then a d < 2 a_d <2 (so a d = 1 a_d =1 ). However, if f ( n ) n f(n) \geq n at a n n with leading digit =1 then f ( 2 1 0 d ) 2 1 0 d f(2 \cdot 10^d) \geq 2 \cdot 10^d (because f f increases at least linearly when the leading digit is 1). By the previous computation, d 5 d \geq 5 which contradicts d < 5 d < 5 .

So the first n n so that f ( n ) n f(n) \geq n is somewhere between 100 000 and 200 000. Note that actually f ( 2 1 0 5 ) = 2 1 0 5 f(2 \cdot 10^5) = 2 \cdot 10^5 . With a computer program (for the range 100000 to 200000), one can check that the first time f ( n ) n f(n) \geq n (in fact =) is at n = 199981 n=199981 .

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...