Find all positive integers that are the cube of the sum of their digits

contest-mathdiophantine equationsdivisibilityelementary-number-theorymodular arithmetic

(HMMT 2000 Guts #5). Find all positive integers that are the cube of the sum of their digits.

I've found a (very) tedious way to resolve the question described below. The tedious part is highlighted in a similar way to the question at the top.

Suppose n is such a number. Note that the sum of the digits of a number is congruent to its remainder modulo 9. So $n^3 \equiv n \mod 9,$ which implies $n\equiv 0,1,-1\mod 9.$ If n has a single digit, then $n=n^3,$ so $n=1$ as $n>0.$ $ n$ is a perfect cube, and the only two digit perfect cubes are $27$ and $64,$ neither of which work, so there are no two-digit solutions. The only three digit perfect cubes are $125,216,343,512,729.$ But $(1+2+5)^3 > 125, (2+1+6)^3 > 216, (3+4+3)^3 > 343, (5+1+2)^3 = 512, (7+2+9)^3 > 729.$ Hence the only three-digit solution is $512.$

Now my question is, is there a better way to solve this question than to literally check all 4 to 6 digit cubes?

Note that there are no solutions with $7$ or more digits, as the largest such number would be $(9\cdot 7)^3 = 250047 < 10^6.$

Best Answer

Let $n=k^3.$ If $n$ has $6$ digits, the largest it could be is $(6\cdot 9)^3 = 157464$, which shows that one digit must be $1$. So in fact the largest it could be is $(1+5\cdot 9)^3 = 97336$ which is too small. So there are no $6$ digit (or larger) solutions. (I think this is the gist of @dezdichado's comment.)

Because the cube root of $100,000 = 46.4\ldots$, we know that $k\leq 46.$ Using your observation that $k\equiv -1, 0, 1 \pmod{9}$ leaves us with only these $16$ possibilities for $k$:

$$1, 8, 9, 10, 17, 18, 19, 26, 27, 28, 35, 36, 37, 44, 45, 46.$$

We can just check these or we can play a bit more:

Since $(5\cdot 9)^3 = 91125$, we see that a $5$-digit solution must have at least one non-$9$ digit. Since $(4\cdot 9+8)^3 = 85184$, the largest the first two digits can be is $79$, so at least one digit is at most $7$. Since $4\cdot 9 +7 = 43$ we can cross off the last three numbers from the list.

Of these, $1, 8, 17, 18, 26, 27$ work.

A couple of observations: It surprises me that the last two pairs are consecutive, and both are of the shape $-1, 0 \pmod{9}$ so I feel like I've missed something. Since $1$ is a solution, it doesn't seem like modular considerations would eliminate $1 \pmod{9}$.