Find the values of f 2018 ( n ) f^{2018}(n)

Define a function f : N 999 N 999 f : \mathbb{N}_{\leq 999} \to \mathbb{N}_{\leq 999} by the following: given n N 999 n \in \mathbb{N}_{\leq 999} , denote its three digits a , b , c a,b,c (including leading zeros) such that a b c a \geq b \geq c . Then f ( n ) = a b c c b a f(n) = \overline{abc} - \overline{cba} . What is the sum of all possible values of f 2018 ( n ) f^{2018}(n) ?

Details and Assumptions:

  • N 999 \mathbb{N}_{\leq 999} refers to the subset of natural numbers { 0 , 1 , 2 , , 998 , 999 } \{0, 1, 2, \dots, 998, 999 \} .
  • x y z \overline{xyz} refers to the number whose base 10 digit representation is written as x y z xyz , where each of x x , y y , and z z are base 10 digits.
  • f k ( n ) f^k(n) denotes the k k -th iteration of f f on n n , that is, f ( f ( f ( n ) ) ) f(f(\dots f(n) \dots )) where the number of f f 's is equal to k k .
  • To give an example of how f f works, f ( 039 ) = 930 039 = 891 f(039) = 930 - 039 = 891 .


The answer is 495.

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.

2 solutions

Otto Bretscher
Oct 10, 2018

My solution is similar to Brian's, but not identical.

If the three digits of n n are identical, then f ( n ) = 0 f(n)=0 and f k ( n ) = 0 f^k(n)=0 for all k k . From now on let's assume that n n has three digits a , b , c a,b,c , in any order, with a b c a\geq b\geq c and a > c a>c . Then f ( n ) = 100 a + 10 b + c ( 100 c + 10 b + a ) = 99 ( a c ) f(n)=100a+10b+c-(100c+10b+a)=99(a-c) . Thus f ( n ) f(n) will be one of the nine numbers 99 k 99k for k = 1 , . . . , 9 k=1,...,9 . Note that the middle digit of 99 k 99k is always 9 9 , the first is k 1 k-1 and the last is 10 k 10-k . The largest digit is a = 9 a=9 and the smallest digit c c is the minimum of k 1 k-1 and 10 k 10-k .

For k = 1 , 2 , 3 , 4 , 5 k=1,2,3,4,5 , the smallest digit of 99 k 99k is c = k 1 c=k-1 , so f ( 99 k ) = 99 ( a c ) = 99 ( 10 k ) f(99k)=99(a-c)=99(10-k) . In particular, f ( 5 × 99 ) = f ( 495 ) = 495 f(5\times99)=f(495)=495 . For k = 6 , 7 , 8 , 9 k=6,7,8,9 , the smallest digit is c = 10 k c=10-k , so f ( 99 k ) = 99 ( a c ) = 99 ( k 1 ) f(99k)=99(a-c)=99(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 100 99 9 × 99 = 891 8 × 99 = 792 7 × 99 = 693 6 × 99 = 594 5 × 99 = 495. 100 \rightarrow 99 \rightarrow 9\times 99=891 \rightarrow 8\times 99 =792 \rightarrow 7\times 99 = 693 \rightarrow 6\times 99=594 \rightarrow 5\times 99 = 495.

Thus the answer is 0 + 495 = 495 0+495=\boxed{495}

Brian Yao
Oct 5, 2018

We show that f 2018 ( n ) = 0 , 495 f^{2018}(n) = 0, 495 . We will see that the number 2018 2018 is not too relevant; the answer is the same for any iteration of at least 6 6 .

Given n N 999 n \in \mathbb{N}_{\leq 999} , let its digits be a b c a \geq b \geq c . If a = b = c a = b = c , then n = a a a n = \overline{aaa} so that f ( n ) = a a a a a a = 0 f(n) = \overline{aaa} - \overline{aaa} = 0 . As f ( 0 ) = 0 f(0) = 0 , it follows that f 2018 ( n ) = 0 f^{2018}(n) = 0 . Otherwise, not all digits of n n are distinct, whereupon we apply the following useful result.

Lemma : Let m m be a number with digits a b > c a \geq b > c . Then f ( m ) = d 9 e f(m) = \overline{d9e} where d = a c 1 d = a - c - 1 and e = 9 d e = 9 - d . Furthermore, d < 9 d < 9 and e > 0 e > 0 .

Proof : By the definition of f f , note that f ( m ) = a b c c b a = 100 a + 10 b + c 100 c 10 b a = 100 ( a c ) + c a = 100 ( a c 1 ) + 10 ( 9 ) + ( 10 ( a c ) ) since c a < 0 = d 9 e , \begin{aligned}f(m) & = \overline{abc} - \overline{cba} \\ & = 100a + 10b + c - 100c - 10b - a \\ & = 100(a - c) + c - a \\ & = 100(a - c - 1) + 10(9) + (10 - (a - c)) && \text{since } c - a < 0 \\ & = \overline{d9e}, \end{aligned} where d = a c 1 d = a - c - 1 and e = 10 ( a c ) = 9 d e = 10 - (a - c) = 9 - d . Note that since a 9 a \leq 9 and c 0 c \geq 0 , a c 9 a - c \leq 9 , and since a > c a > c by assumption, a c > 0 a - c > 0 . This implies 1 a c 9 1 \leq a - c \leq 9 , which gives 0 d 8 0 \leq d \leq 8 and 1 e 9 1 \leq e \leq 9 (this last statement also shows that d d and e e are indeed digits). \blacksquare

Corollary : If a number m m 's digits are 4 4 , 5 5 , and 9 9 in any order, then f ( m ) = 495 f(m) = 495 . In particular, 495 495 is a fixed point of f f .

Proof : By the lemma, f ( m ) = d 9 e f(m) = \overline{d9e} where d = 9 4 1 = 4 d = 9 - 4 - 1 = 4 and e = 9 d = 5 e = 9 - d = 5 . \blacksquare

Letting the digits of n n be denoted by a b > c a \geq b > c , we have by the lemma that f ( n ) = d 9 e f(n) = \overline{d9e} with e = 9 d e = 9 - d . Note that the corollary classifies the behavior of f f when d = 4 d = 4 ; in that case f ( n ) = d 9 e = 495 f(n) = \overline{d9e} = 495 , so since f ( 495 ) = 495 f(495) = 495 , f 2018 ( n ) = 495 f^{2018}(n) = 495 . We consider the remaining two cases.

  • If 5 d 8 5 \leq d \leq 8 , then 9 > d > e > 0 9 > d > e > 0 , so by the lemma, f ( d 9 e ) = d 9 e f(\overline{d9e}) = \overline{d'9e'} where d = 9 e 1 = d 1 d' = 9 - e - 1 = d - 1 and e = 9 d e' = 9 - d' . In particular, the new hundreds digit has decreased by exactly one. Thus, it takes d 4 d - 4 applications of f f to d 9 e \overline{d9e} before the hundreds digit becomes 4 4 , at which point we will have reached the fixed point at 495 495 . In other words, f d 4 ( d 9 e ) = 495 f^{d - 4}(\overline{d9e}) = 495 . Thus, since f ( n ) = d 9 e f(n) = \overline{d9e} , f d 3 ( n ) = 495 f^{d - 3}(n) = 495 . By the corollary, we have f 2018 ( n ) = 495 f^{2018}(n) = 495 .
  • If 0 d 3 0 \leq d \leq 3 , then 6 e 9 6 \leq e \leq 9 . This implies 9 e > d + 2 > d 9 \geq e > d + 2 > d , so by the lemma, f ( d 9 e ) = d 9 e f(\overline{d9e}) = d'9e' where d = 9 d 1 = e 1 d' = 9 - d - 1 = e - 1 and e = 9 d = d + 1 e' = 9 - d' = d + 1 . In particular, since e > d + 2 e > d + 2 , we have d > e d' > e' , which puts the number d 9 e \overline{d'9e'} precisely in the first case, since now 5 d 8 5 \leq d' \leq 8 . By the same argument in the first case, it takes d 4 d' - 4 applications of f f to d 9 e \overline{d'9e'} to reach 495 495 . Since f d 4 ( d 9 e ) = 495 f^{d' - 4}(\overline{d'9e'}) = 495 and f 2 ( n ) = d 9 e f^2(n) = \overline{d'9e'} , we have f d 2 ( n ) = 495 f^{d' - 2}(n) = 495 . By the corollary, we have f 2018 ( n ) = 495 f^{2018}(n) = 495 .

Therefore, when it is not the case that a = b = c a = b = c , f 2018 ( n ) = 495 f^{2018}(n) = 495 . This makes the answer 0 + 495 = 495 0 + 495 = \boxed{495} .

As an additional fact: the proof also shows that for any n N 999 n \in \mathbb{N}_{\leq 999} , either f ( n ) = 0 f(n) = 0 or f 6 ( n ) = 495 f^6(n) = 495 .

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.

A Former Brilliant Member - 2 years, 8 months ago

Log in to reply

Perhaps you misunderstood the definition of f f (let me know if I can make it clearer)? By definition, f ( 459 ) = f ( 495 ) = 954 459 = 495 f(459) = f(495) = 954 - 459 = 495 . So it is not quite a cycle.

Brian Yao - 2 years, 8 months ago

Log in to reply

now I understand... Vincent

A Former Brilliant Member - 2 years, 8 months ago

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...