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 A-Z
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 3-digit number has a 9-digit cube and a 9-digit number can have a sod of at most 9*6=54, which has only two digits; other cubes of 3-digit numbers are even smaller. The largest 4-digit number has 12 digits and their largest sod, even in theory, can only be 9*12=108, a 3-digit number. This continues, so that n can have no more than two digits and the above program tests all 2-digit 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 2012-08-10 12:21:18 |