2016 is absolutely awesome 3

Logic Level 2

For any positive integer k k let f 1 ( k ) f_1(k) denote the sum of the squares of the digits of k k (when written in decimal), and for n 2 n \ge 2 define f n ( k ) f_n(k) iteratively by f n ( k ) = f 1 ( f n 1 ( k ) ) f_n(k)=f_1(f_{n-1}(k)) .

Find f 2017 ( 2016 ) f_{2017}(2016) .


The answer is 42.

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

Starting from k = 2016 k = 2016 and iterating the map “sum of squares of the digits” we obtain the chain 2016 41 17 50 25 29 85 89 145 42 20 4 16 37 58 89 2016 \rightarrow 41 \rightarrow 17 \rightarrow 50 \rightarrow 25 \rightarrow 29 \rightarrow 85 \rightarrow 89 \rightarrow 145 \rightarrow 42 \rightarrow 20 \rightarrow 4 \rightarrow 16 \rightarrow 37 \rightarrow 58 \rightarrow 89 , after which the sequence repeats itself, with period 8 8 .

Thus, f 1 ( 2016 ) = 41 , f 2 ( 2016 ) = 17 f_1(2016) = 41, f_2(2016) = 17 , etc., and f n + 8 ( 2016 ) = f n ( 2016 ) f_{n+8}(2016) = f_n(2016) for all integers n 7 n \ge 7 .

Since 2017 = 8.251 + 9 2017 = 8 . 251 + 9 , it follows that follows that f 2017 ( 2016 ) = f 9 ( 2016 ) = 42 f_{2017}(2016) = f_9(2016) = 42 .

Yes Same Way! Is there any other method?

Kushagra Sahni - 5 years, 6 months ago

I solved it this way as well - if you are good at carrying out simple calculations it is a very easy problem.

Thomas Sutcliffe - 3 years, 7 months ago

@Khang Nguyen Thanh I apologise for this strange question, but is there a reason why such a cycle would exist?

John Frank - 3 years, 2 months ago

Log in to reply

One reason (probably not the best) to thik about a cycle is that Any number with 4 digits have f(a) with less than 4 digits, therefore you know that when you apply f a certain number of times you will find a same value again at somepoint and therefore enter into a cycle. As many numbers have the same “f” you can hope to fall into a cycle very quickly

Omar Rekhis - 2 years, 7 months ago
Masbahul Islam
Jan 4, 2016

def a(n):

s=0

x=str(n)

for i in range(len(x)):

    y=int(x[i])

    s=s+y*y

return s

f1=a(2016)

for i in range(1,2017):

f2=a(f1)

f1=f2

print f2

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...