LIST all the integers equal to the sum of the digits of their cubes.
Prove that your list is exhaustive.
DECLARE FUNCTION sod# (n#)
DEFDBL AZ
FOR n = 0 TO 99
s = sod(n * n * n)
IF s = n THEN PRINT n
NEXT n
FUNCTION sod (n)
st$ = LTRIM$(STR$(n))
t = 0
FOR i = 1 TO LEN(st$)
t = t + VAL(MID$(st$, i, 1))
NEXT
sod = t
END FUNCTION
finds
0
1
8
17
18
26
27
The largest 3digit number has a 9digit cube and a 9digit number can have a sod of at most 9*6=54, which has only two digits; other cubes of 3digit numbers are even smaller. The largest 4digit number has 12 digits and their largest sod, even in theory, can only be 9*12=108, a 3digit number. This continues, so that n can have no more than two digits and the above program tests all 2digit numbers, so that the list is complete.
# of digits largest # of digits of sod(cube)
(n) (ceil(log(n*3*9)))
1 2
2 2
3 2
4 3
5 3
6 3
...
19 3
20 3
37 3
38 4

Posted by Charlie
on 20120810 12:21:18 