The number $512$ is interesting because it is equal to the sum of its digits raised to some power: $5 + 1 + 2 = 8$, and $8^3 = 512$. Another example of a number with this property is $614656 = 28^4$.
We shall define $a_n$ to be the $n$th term of this sequence and insist that a number must contain at least two digits to have a sum.
You are given that $a_2 = 512$ and $a_{10} = 614656$.
Find $a_{30}$.
The task requires to generate numbers (with at least two digits) which are equal to the sum of their digits raised to a certain power.
Firstly, let’s consider the highest possible sum of the digits, which is $9*9=81$. Thus, $81^n$ with n ≥ 2 will exceed the digital sum limit after $81^5=3486784401$, which is a 10-digit number. Therefore, we only need to consider powers up to the fifth.
Secondly, we need to calculate the powers of numbers from 2 (the minimum sum with at least two digits) to 81 (the maximum sum with 9 digits).
After we have all 2-digit numbers, we can add them to the sequence if they are “valid” (if they are equal to the sum of their digits raised to a certain power). Each valid number should be added to a list along with its sum value and exponent.
We follow this process for all the valid 2-digits numbers in ascending order until we find the 30th one, which will be our result.
However, this process involves complex calculations and searching algorithms which cannot be performed by a human tutor without the help of a computer program. The pseudo-code for the algorithm would be as follows:
“`
1. Initialize an empty list of `validNumbers`.
2. For each n in the range 2 to 5,
For each number in the range 2 to 81,
Calculate power = number^n.
If power has more than one digit and
the sum of the digits of `power` equals `number`,
Add `power` to `validNumbers`.
3. Sort the `validNumbers`.
4. Return the 30th element in `validNumbers`.
“`
Again, this problem involves number theory and programming that usually needs the help of a computer to solve.
More Answers:
Red, Green or Blue TilesRed, Green, and Blue Tiles
Pandigital Prime Sets