OFFSET
1,2
COMMENTS
Starting with a(7), follows the pattern 21^k, 1^k2, 121^k, 1^(k+1)21, 2(1)^(k+1), ..., for k >= 2, where ^ represents repeated concatenation. - Michael S. Branicky, Aug 09 2022
PROG
(Python)
from itertools import count, islice, product
def pals(digs):
yield from digs
for d in count(2):
for p in product(digs, repeat=d//2):
left = "".join(p)
for mid in [[""], digs][d%2]:
yield left + mid + left[::-1]
def folds(s): # generator of suffixes of palindromes starting with s
for i in range((len(s)+1)//2, len(s)+1):
for mid in [True, False]:
t = s[:i] + (s[:i-1][::-1] if mid else s[:i][::-1])
if t.startswith(s):
yield t[len(s):]
yield from ("".join(p)+s[::-1] for p in pals("12"))
def agen():
s, seen = "1", {"1"}; yield 1
while True:
for t in folds(s):
if len(t) > 0 and set(t) != {"1"} and t not in seen: break
s = t; seen.add(t); yield int(t)
print(list(islice(agen(), 33))) # Michael S. Branicky, Aug 09 2022
CROSSREFS
KEYWORD
base,nonn
AUTHOR
Amarnath Murthy and Meenakshi Srikanth (menakan_s(AT)yahoo.com), Apr 23 2003
EXTENSIONS
Corrected and extended by Ray G. Opao, Sep 22 2005
a(18) and beyond from Michael S. Branicky, Aug 09 2022
STATUS
approved