The sequence formula is n^2 - n + 1.
The 600th is 359,401.
343 (the 19th member) is the perfect cube.
10101 (the 101st member) is the palindrome.
The 500th member is the lower of the two that differ by 1000, and is 249,501.
The program uses increasing first differences, rather than the formula:
diff = 2: n = 1
DO
ct = ct + 1
IF ct = 600 THEN PRINT "600th="; n
tst = INT(n ^ (1 / 3) + .5): tcu = tst * tst * tst
IF tcu = n THEN PRINT "cube "; n; ct
ns$ = LTRIM$(STR$(n))
IF LEN(ns$) = 5 THEN
IF LEFT$(ns$, 1) = RIGHT$(ns$, 1) AND MID$(ns$, 2, 1) = MID$(ns$, 4, 1) THEN
good = 1
FOR i = 1 TO 3
IF INSTR("01", MID$(ns$, i, 1)) = 0 THEN good = 0
NEXT
IF good THEN
PRINT "bin pal="; n; ct
END IF
END IF
END IF
IF diff = 1000 THEN PRINT "lower="; n; ct
n = n + diff
diff = diff + 2
LOOP UNTIL ct > 600 AND diff > 1000
which results in:
cube 1 1
cube 343 19
bin pal= 10101 101
lower= 249501 500
600th= 359401
From Enigma No. 1436 by Adrian Somerfield, New Scientist, 31 March 2007 |