OFFSET
1,2
COMMENTS
EXAMPLE
For n = 3 concatenation of the previous terms is 121. Numbers that would make it a palindrome if concatenated to it are 121, 1121, ... and the second smallest of them is a(3) = 1121.
PROG
(Python)
pal = lambda s: s == s[::-1]
up_to = 10
terms = [1, ]
for i in range(up_to-1):
c, r = ''.join(map(str, terms)), 0
for j in range(len(str(terms[-1])), len(c)+1):
found, p = False, int(c[:j][::-1])
if p > terms[-1] and pal(c + c[:j][::-1]):
r+=1
if r == 2:
terms.append(p); found = True; break
if found: continue
j = 0
while 1:
j+=1
r+=1
if r == 2:
terms.append(int(str(j) + c[::-1]))
break
print(terms)
CROSSREFS
KEYWORD
nonn,base
AUTHOR
Gleb Ivanov, Sep 23 2022
STATUS
approved