Define a function f : N ≤ 9 9 9 → N ≤ 9 9 9 by the following: given n ∈ N ≤ 9 9 9 , denote its three digits a , b , c (including leading zeros) such that a ≥ b ≥ c . Then f ( n ) = a b c − c b a . What is the sum of all possible values of f 2 0 1 8 ( n ) ?
Details and Assumptions:
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.
We show that f 2 0 1 8 ( n ) = 0 , 4 9 5 . We will see that the number 2 0 1 8 is not too relevant; the answer is the same for any iteration of at least 6 .
Given n ∈ N ≤ 9 9 9 , let its digits be a ≥ b ≥ c . If a = b = c , then n = a a a so that f ( n ) = a a a − a a a = 0 . As f ( 0 ) = 0 , it follows that f 2 0 1 8 ( n ) = 0 . Otherwise, not all digits of n are distinct, whereupon we apply the following useful result.
Lemma : Let m be a number with digits a ≥ b > c . Then f ( m ) = d 9 e where d = a − c − 1 and e = 9 − d . Furthermore, d < 9 and e > 0 .
Proof : By the definition of f , note that f ( m ) = a b c − c b a = 1 0 0 a + 1 0 b + c − 1 0 0 c − 1 0 b − a = 1 0 0 ( a − c ) + c − a = 1 0 0 ( a − c − 1 ) + 1 0 ( 9 ) + ( 1 0 − ( a − c ) ) = d 9 e , since c − a < 0 where d = a − c − 1 and e = 1 0 − ( a − c ) = 9 − d . Note that since a ≤ 9 and c ≥ 0 , a − c ≤ 9 , and since a > c by assumption, a − c > 0 . This implies 1 ≤ a − c ≤ 9 , which gives 0 ≤ d ≤ 8 and 1 ≤ e ≤ 9 (this last statement also shows that d and e are indeed digits). ■
Corollary : If a number m 's digits are 4 , 5 , and 9 in any order, then f ( m ) = 4 9 5 . In particular, 4 9 5 is a fixed point of f .
Proof : By the lemma, f ( m ) = d 9 e where d = 9 − 4 − 1 = 4 and e = 9 − d = 5 . ■
Letting the digits of n be denoted by a ≥ b > c , we have by the lemma that f ( n ) = d 9 e with e = 9 − d . Note that the corollary classifies the behavior of f when d = 4 ; in that case f ( n ) = d 9 e = 4 9 5 , so since f ( 4 9 5 ) = 4 9 5 , f 2 0 1 8 ( n ) = 4 9 5 . We consider the remaining two cases.
Therefore, when it is not the case that a = b = c , f 2 0 1 8 ( n ) = 4 9 5 . This makes the answer 0 + 4 9 5 = 4 9 5 .
As an additional fact: the proof also shows that for any n ∈ N ≤ 9 9 9 , either f ( n ) = 0 or f 6 ( n ) = 4 9 5 .
Hi there, I really like your question. Here is a question though. Don't you think 459 can also be a possible value? after all there is only one cycle of length two, with respect to the function f, namely the cycle (459,495). Since 2018 is an even integer, if you start with one of them, you get back to the same number.
Log in to reply
Perhaps you misunderstood the definition of f (let me know if I can make it clearer)? By definition, f ( 4 5 9 ) = f ( 4 9 5 ) = 9 5 4 − 4 5 9 = 4 9 5 . So it is not quite a cycle.
Problem Loading...
Note Loading...
Set Loading...
My solution is similar to Brian's, but not identical.
If the three digits of n are identical, then f ( n ) = 0 and f k ( n ) = 0 for all k . From now on let's assume that n has three digits a , b , c , in any order, with a ≥ b ≥ c and a > c . Then f ( n ) = 1 0 0 a + 1 0 b + c − ( 1 0 0 c + 1 0 b + a ) = 9 9 ( a − c ) . Thus f ( n ) will be one of the nine numbers 9 9 k for k = 1 , . . . , 9 . Note that the middle digit of 9 9 k is always 9 , the first is k − 1 and the last is 1 0 − k . The largest digit is a = 9 and the smallest digit c is the minimum of k − 1 and 1 0 − k .
For k = 1 , 2 , 3 , 4 , 5 , the smallest digit of 9 9 k is c = k − 1 , so f ( 9 9 k ) = 9 9 ( a − c ) = 9 9 ( 1 0 − k ) . In particular, f ( 5 × 9 9 ) = f ( 4 9 5 ) = 4 9 5 . For k = 6 , 7 , 8 , 9 , the smallest digit is c = 1 0 − k , so f ( 9 9 k ) = 9 9 ( a − c ) = 9 9 ( k − 1 ) .
It follows that we will reach the fixed point 495 after at most 6 iterations, and certainly after 2018. The longest chain of distinct numbers is generated when the "seed" maps to 99, as in 1 0 0 → 9 9 → 9 × 9 9 = 8 9 1 → 8 × 9 9 = 7 9 2 → 7 × 9 9 = 6 9 3 → 6 × 9 9 = 5 9 4 → 5 × 9 9 = 4 9 5 .
Thus the answer is 0 + 4 9 5 = 4 9 5