{75, 100, 125} is an example of an arithmetic progression of positive integers such that the n-th term is a perfect n-th power.
Find a longer sequence with this feature.
What is the longest you can get?
P.S. Trival solution(d=0) excluded.
50 dim h(12)
100 FOR sr = 1 TO 1000
110 sq = sr * sr
120 cr0 = -INT(-(sq ^ (1 / 3)))
130 FOR cr = cr0 TO cr0 + 1000
140 cu = cr * cr * cr
150 diff = cu - sq
160 IF diff > 0 THEN
170 : pwr = 3: rslt = cu
180 : repeat
190 : pwr = pwr + 1
200 : rslt = rslt + diff
210 : root = INT(rslt ^ (1 / pwr) + .5)
220 : rchk = 1
230 : good = 0
240 : FOR i = 1 TO pwr
250 : rchk = rchk * root
260 : NEXT
270 : IF rchk = rslt THEN good = 1:endif
280 : IF good THEN h(pwr) = rslt:endif
290 : until good = 0
300 : pwr = pwr - 1
310 : IF pwr >= max AND pwr > 3 THEN
320 : PRINT pwr, sq; cu;
330 : FOR i = 4 TO pwr
340 : PRINT h(i);
350 : NEXT
360 : PRINT
370 : END IF
380 :END IF
390 NEXT
400 NEXT
finds 4 as the highest power within its range of up to 10,000 for the square root of the square term, and up to 10,000 for the difference in the arithmetic sequence:
run
4 90000 125000 160000
4 1194649 48627125 96059601
4 15816529 1532808577 3049800625
4 44289025 8703679193 17363069361
4 73530625 1838265625 3603000625
OK
These represent only the 2nd, 3rd and 4th powers. But all except the first shown would result in the first term being negative, thus disqualifying the whole series.
Thus the best progression found by the program is {55000, 90000, 125000, 160000}.
Now that I have seen Justin's series, with negative d, a variation allowing such is:
50 dim H(12)
100 for Sr=1 to 400
110 Sq=Sr*Sr
120 Cr0=-int(-(Sq^(1/3)))
130 for Cr=1 to 1000
140 Cu=Cr*Cr*Cr
150 Diff=Cu-Sq
160 if Diff<>0 then
170 :Pwr=3:Rslt=Cu
180 :repeat
190 :Pwr=Pwr+1
200 :Rslt=Rslt+Diff
210 :Root=int(abs(Rslt)^(1/Pwr)+0.5)
220 :Rchk=1
230 :Good=0
240 :for I=1 to Pwr
250 :Rchk=Rchk*Root
260 :next
270 :if Rchk=Rslt then Good=1:endif
280 :if Good then H(Pwr)=Rslt:endif
290 :until Good=0
300 :Pwr=Pwr-1
310 :if Pwr>=Max and Pwr>3 then
320 :print Pwr,Sq;Cu;
330 :for I=4 to Pwr
340 :print H(I);
350 :next
360 :print
370 :endif
380 :endif
390 next
400 next
which finds
run
4 16 8 0
4 169 125 81
4 1024 512 0
4 11664 5832 0
4 30625 15625 625
4 33856 17576 1296
4 65536 32768 0
4 90000 125000 160000
4 123201 68921 14641
4 123904 64000 4096
with the first power extrapolated back from the 2nd, 3rd and 4th powers shown. Justin's solution is the second row. A ones with 0 as the 4th power fail to satisfy the requirement for positive integers.
|
Posted by Charlie
on 2010-07-22 16:13:40 |