Consider a n digit integer x = a n a n − 1 ⋯ a 1 .
Let us call the number x to be self obsessed if
x = a n a n − 1 ⋯ a 1 = a n a n + a n − 1 a n − 1 + ⋯ + a 1 a 1 .
It is easy to see that the smallest such integer is x = 1 .
What is the next integer with this property?
HINT : 0 0 is . Hence, the answer cannot have zero as one of its digits.
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.
1 2 3 4 5 |
|
Simple standard approach.
3 3 + 4 4 + 3 3 + 5 5 = 2 7 + 2 5 6 + 2 7 + 3 1 2 5 = 3 4 3 5
Just a cool fact: these are called Münchhausen numbers! The next one, courtesy of OEIS, is 438579088.
Log in to reply
That is assuming 0 0 = 0 if you read the hint in the question, it eliminates 438579088.
1 2 3 4 5 6 7 8 9 |
|
Simple enough approach, using string manipulation and breaking out of infinite loops.
The hint is useful. You can also eliminate some wasted time by noting that there is no point in adding terms once the sum is at least as great as x .
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
|
Here is a J A V A code for this problem.
It must be a computer Science problem.
But solvable using the pencil & paper approach as well. I did it that way, so it's not a rigid cs problem.
Problem Loading...
Note Loading...
Set Loading...
C++
Output: