Solution to October 2004 Problem

In Ira Hauptmann's play Partition, which is playing to sell-out crowds around the world, Ramanujan tells Hardy that 153 is indeed an interesting number.

"It equals the sum of the cubes of its digits:

153 = 13 + 53 + 33.

And I know that there are, in all, just five positive base-10 numbers
that equal the sum of the cubes of their digits."

 Show that Ramanujan is correct.

Solution to MP44

We received correct solutions from Alexander Akulov (Regina), Ernest Creiser (France), Xavier Hecquet (France), Wolfgang Kais (Germany), and Lionel Ruiz (France).  Everybody quickly noticed that there is no need to consider numbers having more than four digits: The sum of the cubes of n single-digit numbers can be at most 93n = 729n.  For n > 4 this number is considerably less than the smallest n-digit number, namely 10n-1 = 103·10n-4.  Indeed, for four digits, 4·729 = 2916 so, letting the digits be a, b, c, and d, one only has to check for 2916 cases whether

a·103 + b·10 + d = a3 + b3 + c3 + d3

A computer can easily be programmed to exhaust these possibilities and agree with Ramanujan –

1, 153, 370, 371, and 407are the five numbers that equal the sum of the cubes of their digits.

 All the submitted solutions used a computer at some point, which is only fair since Ramanujan is reputed to have been as fast as a computer in such tasks.  On the other hand, both Akulov and Kais brought the list of cases to be checked down to a number that anybody could verify by hand.

 For a 1-digit number we only have to solve d = d3 for the unique solution d = 1.  (We are working with positive numbers, which means that at least one digit exceeds 0; for d > 1, we have d3 > d.)

For a 2-digit number c ≠ 0 and we solve 10c + d = c3 + d3:

c(10 – c2) = d3 – d ≥ 0.

For the left-hand side to be positive, c must lie between 0 and √10.  That means we only have to check c = 1, 2, 3, for which the left-hand side is 9, 12, and 3, respectively.  The possibilities on the right are 0, 1, and 2, for which the right-hand side is 0, 0, and 6. (For d bigger than 2, d3 – d > 12.)  We conclude that the equation cannot be satisfied, so no 2-digit number satisfies Ramanujan’s condition.

For 3- and 4-digit numbers we deduce from equation (1) that

a(103 - a2) + b(102 - b2) = c(c2 - 10) + d(d2 - 1)                        (2)

The right-hand side of (2) can assume fewer than 100 values, namely the sum of an element from each row of the following table:

digit value -> 0 1 2 3 4 5 6 7 8 9
d(d2 - 1) 0 0 6 24 60 120 210 336 504 720
c(c2 - 10) 0 -9 -12 -3 24 75 156 273 432 639

Kais draws two quick observations from this table.  First, since each residue modulo 10 appears in the second row, there is no obvious quick way to eliminate possibilities.  Second, the largest sum on the right-hand side of (2) is 1359 (when c = d = 9); therefore the digit a (on the left) can be at most 1 (since a ≥ 2 implies a(1000 – a2) ≥ 1992).  That allows just the 19 possibilities for the left-hand side of (2) that are given in the following table.  The first row has a = 0, the second has a = 1.

b 0 1 2 3 4 5 6 7 8 9
b(100 - b2) -- 99 192 273 336 375 384 357 288 171
999 + b(100 - b2) 000 1098 1191 1272 1335 1374 1383 1356 1287 1170

For each of these 19 possible sums on the left of (2), we need only check a few values of c and d to see if equation (2) can be satisfied.  For example, with a = 0 and b = 2, the left-hand side of (2) is 192.  For d we look at values up to d = 5, and match them with values of c up to 6. It takes no more than a moment or two to see that no combination sums to 192.  Similarly, when a = 0 and b = 3, the sum to be matched is 273; that sum can be achieved on the right when c = 7 (meaning c(c2 – 10) = 273) and d = 0 or 1 (for which d(d2 – 1) = 0).