Find the largest positive integer with the property that each digit apart from the first and the last one is smaller than the arithmetic mean of her neighbours.
Problem
Source: Bundeswettbewerb Mathematik 2018, Round 1 - #1
Tags: Digits, number theory, arithmetic
06.07.2018 15:21
Let $N$ be a positive integer with $n$ digits which satisfies the given property. Let $a_k$ be digit number $k$ when you read $N$ from left to right. Hence $N = a_na_{n-1} \ldots a_2a_1$, which according to the given property means ${\textstyle (1) \;\; \frac{a_k + a_{k-2}}{2} = a_{k-1} + 1}, \;\; 3 \leq k \leq n$. Formula (1) is equivalent to $(2) \;\; a_k = 2a_{k-1} – a_{k-2} + 2$. The recursive formula (2) give us the explicit formula (can be verified by induction) $(3) \;\; a_k = (k - 1)a_2 - (k - 2)a_1 + (k - 1)(k - 2)$. Consequently by (3) we obtain $(4) \;\; a_k - a_1 = (k - 1)(a_2 - a_1 + k - 2)$ and $(5) \;\; a_k - a_2 = (k - 2)(a_2 - a_1 + k - 1)$. Assume $n \geq 7$. Let us consider the following cases: Case 1: $a_2 - a_1$ is even. Inserting $k=7$ in (5), the result is $(6) \;\; a_7 - a_2 = 5(a_2 - a_1 + 6)$. Hence $10 \mid a_7 - a_2$ by (6), yielding $a_7 = a_2$ (since $0 \leq a_2,a_7 \leq 9$ implies $|a_7 - a_2| \leq 9$), which inserted in (6) give us $a_2 - a_1 + 6 = 0$. Therefore by (4) $(7) \;\; a_k = (k - 1)(k - 8) + a_1$. Setting $k=3$ in (7) yields $a_3 = a_1 - 10 \leq -1$ since $a_1 \leq 9$. This contradiction implies there is no N satisfying (1). Case 2: $a_2 - a_1$ is odd. Inserting $k=7$ in (4), the result is $(8) \;\; a_7 - a_1 = 6(a_2 - a_1 + 5)$. Hence $12 \mid a_7 - a_1$ by (8), yielding $a_7 = a_1$ (since $0 \leq a_1,a_7 \leq 9$ implies $|a_7 - a_1| \leq 9$), which inserted in (8) give us $a_2 - a_1 + 5 = 0$. Therefore by (4) $(9) \;\; a_k = (k - 1)(k - 7) + a_1$. Setting $k=4$ in (7) yields $a_4 = a_1 - 9 \geq 0$, yielding $a_1 \geq 9$. Hence $a_1=9$ (since $a_1 \leq 9$), which inserted in (9) give us $(10) \;\; a_k = (4 - k)^2$. From (10) we obtain $0 \leq a_k \leq 9$ iff $1 \leq k \leq 7$. In other words, the largest integer $N$ which satisfies property (1) is $N = 9410149$.
27.10.2018 11:54
I believe 9521259 is larger than the one you wrote.
27.10.2018 11:54
96433469
16.11.2018 21:10
For starters, we will work in base $B$ because it's cooler and nobody specified that this problem is to be solved in base 10. Let $a_k$ be the smallest digit in the number and its first appearance. It may have at most one neighbour of the same value, because, obviously, if there were 3 consecutive digits of the same value, the middle digit would be the mean of its neighbours. If there were only one digit, then $a_{k-1}$ and $a_{k+1}$ would both be greater than $a_k$, so if we were to put another digit of the same value as $a_k$ between them, the property would still hold true and the number would be bigger. So we may assume that $a_k$ and $a_{k+1}$ are the minimum digit. We will also prove by induction that $a_{k-i} - a_{k-i+1} \geq i$ Obviously, it is true for $i=1$. Assuming that it is true for $i - 1$, $a_{k-i} - a_{k-i+1} \geq a_{k-i+1} - a_{k-i+2} + 1 \geq i - 1 + 1 = i$ Now, $a_{k-1}$ is at least $a_k + 1$, then $a_{k-2}$ is at least $2a_{k-1} - a_k+1 \geq a_{k} + 3$ and so on, by induction (which is that $a_{k-i+1} \geq a_k+\frac{(i-1)i}{2}$), $a_{k-i}$ is at least $a_{k-i+1} + i \geq a_k + \frac{i(i + 1)}{2}$ Therefore, $a_1 \geq a_k + \frac{k(k - 1)}{2} \geq \frac{k(k - 1)}{2}$ Equality can be found in the case in which $a_k=0$ But we also know that: $a_1 \leq B-1$ Then: $\frac{k(k-1)}{2} \leq B-1$ $k(k - 1) \leq 2B - 4$ $k \leq \frac{1 + \sqrt{8B - 7}}{2}$ $k \leq \lfloor\frac{1 + \sqrt{8B - 7}}{2}\rfloor$ To maximize the number, we'll have $k$ equal to that number and $a_1 = B - 1, a_2 = B - k, \dots a_k = B - 1 - \frac{k(k - 1)}{2}$, because $a_1$ has to be $B-1$ in the maximum number or we could increase it and keep the initial property, which would be false. And, regarding $a_i$, it has to be at most $a_{i-1}-k+i$, and after we showed that, by induction for $j=1, 2, i-1$, $a_j\leq B-1-\frac{(k-1)k-(k-j)(k-j+1)}{2}$. $a_i\leq a_{i-1} - k + i \leq B-1-\frac{(k-1)k-(k-i)(k-i+1)}{2}$ Then we can conclude that: $a_i=B-1-\frac{(k-1)k-(k-i)(k-i+1)}{2}, i=1, 2, \dots, k$ We will do the same for the other half of the number. Let $n$ be the number of digits. Since all inequalities from above still hold true for the other half, only in reverse, we'll have: $n - (k + 1) + 1 = n - k \leq \frac{1 + \sqrt{8B - 7}}{2}$ Then $n \leq 2\lfloor\frac{1 + \sqrt{8B - 7}}{2}\rfloor = 2k$ And, to, again, maximize the number, we'll mirror what we did in the other half of the number. If the last digit is not $B-1$, we can obtain a bigger number. By induction, $a_{n-i-1} \leq a_{n-i}-k+i+1$, and we'll maximize it by giving it that value. Therefore, the digits will be: $a_i=a_{n-i+1}=B-1-\frac{(k-1)k-(k-i)(k-i+1)}{2}, i=1, 2, \dots, k$ $n = 2\lfloor\frac{1 + \sqrt{8B - 7}}{2}\rfloor = 2k$ In the particular case in which we're working in base $10$, we have $k = \lfloor\frac{1 + \sqrt{77}}{2}\rfloor$ $k = 4$ $n = 2k = 8$ $a_1 = B - 1 = 9$ $a_2 = a_1 - (k - 1) = 6$ $a_3 = a_2 - (k - 2) = 4$ $a_4 = a_3 - (k - 3) = 3$ $a_5 = a_{n-5+1} = 3$ $a_6 = a_{n-6+1} = 4$ $a_7 = a_{n-7+1} = 6$ $a_8 = a_{n-8+1} = 9$ The number we are searching for is $96433469$