OFFSET
0,3
COMMENTS
If instead we set a(n) = pal(a(n-1)), the sequence would have to start at the twelfth palindrome 22, and go from there: 12, 22, 121, 2112, 1112111, 112111111211, 1211111121111211111121, 211111121111211111121121111112111121111112, ..., . This sequence is interesting in that only the digits 1 and 2 appear so far (tested out to seventeen terms).
LINKS
Hiroaki Yamanouchi, Table of n, a(n) for n = 0..21
Hiroaki Yamanouchi, Python source code
EXAMPLE
For n=11, we have a(10)=11=pal(11), a(10)-a(9)=11-9=2, so a(11) = pal(11+2) = pal(13) = 33.
a(12) = 252 because it is the twenty-second palindrome after 13, the difference between 11 and 33.
MATHEMATICA
NextPalindrome[n_] := Block[{l = Floor[ Log[ 10, n] + 1], idn = IntegerDigits[ n]}, If[ Union[ idn] == {9}, Return[n + 2], If[l < 2, Return[n + 1], If[ FromDigits[ Reverse[ Take[ idn, Ceiling[l/2]]]] > FromDigits[ Take[ idn, -Ceiling[l/2]]], FromDigits[ Join[ Take[ idn, Ceiling[l/2]], Reverse[ Take[ idn, Floor[l/2]]]]], idfhn = FromDigits[ Take[ idn, Ceiling[l/2]]] + 1; idp = FromDigits[ Join[ IntegerDigits[ idfhn], Drop[ Reverse[ IntegerDigits[ idfhn]], Mod[l, 2]]]]]]]]; f[s_List] := Block[{a = s[[-1]], b = s[[-2]]}, Append[s, Nest[ NextPalindrome@# &, a, a - b]]]; s = {0, 1}, Nest[f, s, 14]
nthPalindrome[n_] := Block[{q = n + 1 - 10^Floor[ Log10[n + 1 - 10^Floor[ Log10[ n/10]] ]], c = Sum[ Floor[ Floor[ n/(11*10^(k - 1) - 1)]/(Floor[ n/(11*10^(k - 1) - 1)] - 1/10)] - Floor[ Floor[ n/(2*10^k - 1)]/(Floor[ n/(2*10^k - 1)] - 1/10)], {k, Floor[ Log10[ n]] }]}, Mod[q, 10]*11^c*10^Floor[ Log10[ q]] + Sum[ Floor[ Mod[q, 10^(k + 1)]/10^k]*10^(Floor[ Log10[ q]] - k) (10^(2 k + c) + 1) , {k, Floor[ Log10[ q]] }]] (* after the work of Eric A. Schmidt, see A002113 *) s = {0}; f[s_List] := Block[{k = s[[-1]] + 1}, Append[s, nthPalindrome[ k]]]; Nest[f, s, 18] (* Robert G. Wilson v, Sep 22 2014 *)
PROG
(Python)
from itertools import islice
def A246008_gen(): # generator of terms
a, b, k = 0, 1, 2
yield 0
while True:
yield b
a, b = b, int((c:=k-x)*x+int(str(c)[-2::-1] or 0) if (k:=k+b-a)<(x:=10**(len(str(k>>1))-1))+(y:=10*x) else (c:=k-y)*y+int(str(c)[::-1] or 0))
CROSSREFS
KEYWORD
nonn,base
AUTHOR
Robert G. Wilson v, Sep 20 2014
EXTENSIONS
a(16)-a(17) from Hiroaki Yamanouchi, Sep 21 2014
Edited by N. J. A. Sloane, Oct 01 2014
STATUS
approved