More fun in 2016, Part 15

Logic Level 3

n + S ( n ) + S ( S ( n ) ) = 2016 n+S(n)+S(S(n))=2016

Find the smallest positive integer n n that satisfies the equation above, where S ( n ) S(n) denotes the digit sum of n n .

Source


The answer is 1986.

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

Zee Ell
Jan 4, 2016

Let A(n) = n + S(n) + S(S(n)) = 2016

First, we will find a lower boundary for n.

As the biggest 3-digit number is 999, the maximum for S(n) is 9×3 =27, and the biggest value for S(S(n)) is 10 (when S(n)=19), the biggest value which we can achieve, cannot be bigger, than

999 + 27 + 10 = 1036 (and it is also easy to see, that the actual maximum value is 1035) , which is much smaller, than 2016.

Hence, we have to look for a 4-digit number.

As the smallest 4 digit numbers start with 1 and 2016 is very close to 1999, we will look for numbers between 1000 and 1999 first.

Now, we can find a lower boundary for n.

n is minimal, when S(n) and S(S(n)) are maximal (as their sum with n is constant).

The maximum value of S(n) is 1+ 9 + 9 + 9 = 28, and the maximum value of S(S(n)) is 10 (both at 28 and 19).

Therefore, the minimum value for n is not smaller, than

2016 - 28 - 10=1978

While A(1978)= 1978 + 25 + 7 = 2010 is not the solution (too small), by examining the values of A(n) for values of n slightly greater, than 1978, we will get our solution ( n = 1986 n= \boxed {1986} ) quickly.

A(1986)= 1986 + 24 + 6 = 2016

Yes same way.

Kushagra Sahni - 5 years, 5 months ago

And to examine the values of A(n) in a faster way, we can take modulus 9 of the original equation to see that n has to be a multiple of 3

展豪 張 - 5 years, 3 months ago

Well explained! (+1) I did it pretty much the same way.

Otto Bretscher - 5 years, 5 months ago
Masbahul Islam
Jan 4, 2016

def d(n):

s=0

x=str(n)

for i in range(len(x)):

    s=s+int(x[i])

return s

for n in range(2016):

x=n+d(n)+d(d(n))

if x==2016:

    print n

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...