We have two functions of t: t^2 and the cube of the sum of the digits of t. We want to know for what values of t these two functions are equal. If we seek the answers by exhaustively looking at values of t up to a certain point, we want to be assured that no more solutions will lie above that value of t.
If we let n = the number of digits in t, and specify these functions, expressed in terms of n, for the upper limit of either the ratio or the difference between the cube of the s.o.d. and the square of the original number, that upper limit is reached when all the digits are 9, as in 9, 99, 999, etc.
The square of t is going to be very close to 10^(2*n), while the cube of the sum of the digits is at most 729*n^3. The exponential increases, of course, exponentially with n, while the cubic is merely that, a cubic in n. Here's a table of values of t^2 vs. the cube of the sum of the digits, at those places (all-9's) where the cubic has the best chance against the exponential in n:
t t^2 cube of sum of digits
9 81 729
99 9801 5832
999 998001 19683
9999 99980001 46656
99999 9999800001 91125
999999 999998000001 157464
9999999 99999980000001 250047
99999999 9999999800000001 373248
999999999 999999998000000001 531441
If we test t up to 1,000,000, we've passed the point in the table where we got
999999 999998000001 157464
so we can safely say we've got them all, as the smallest t^2 for a 7-digit number is 10^12, while the largest cube of s.o.d. for a 7-digit number is 250,047.
In fact, we could have stopped with 3-digit numbers, as the smallest t^2 for a 4-digit number is 1,000,000, while the largest cube of s.o.d. for a 4-digit number is 46,656.
DEFDBL A-Z
FOR i = 1 TO 1000000
sq = i * i
n$ = LTRIM$(STR$(i))
t = 0
FOR j = 1 TO LEN(n$)
t = t + VAL(MID$(n$, j, 1))
NEXT
cube = t * t * t
IF sq = cube THEN PRINT i, sq, cube
NEXT
which gives two solutions: 1 and 27:
1 1 1
27 729 729
Edited on October 10, 2007, 11:00 am
|
Posted by Charlie
on 2007-10-10 10:44:56 |