[go: up one dir, main page]

login
A357044
Lexicographic earliest sequence of distinct palindromes (A002113) such that a(n)+a(n+1) is never palindromic.
1
1, 9, 3, 7, 5, 8, 2, 11, 4, 6, 22, 88, 44, 66, 77, 33, 99, 55, 101, 909, 111, 191, 121, 181, 131, 171, 141, 161, 151, 252, 262, 242, 272, 232, 282, 222, 292, 212, 393, 313, 494, 323, 383, 333, 373, 343, 363, 353, 454, 464, 444, 474, 434, 484, 424
OFFSET
1,2
COMMENTS
Obviously the sequence cannot contain 0.
It is easy to prove that the sequence is a permutation of the nonzero palindromes (in the sense that it contains each of them exactly once).
LINKS
Eric Angelini, Sums with palindromes, personal blog "Cinquante signes" on blogspot.com, and post to the math-fun list, Sep 12 2022
PROG
(PARI) A357044_first(n, U=[0], a=9)={vector(n, k, k=U[1]; while(is_A002113(a+k=A262038(k+1)) || setsearch(U, k), ); U=setunion(U, [a=k]); while(#U>1 && U[2]==A262038(U[1]+1), U=U[^1]); a)}
(Python)
from itertools import count, islice
def ispal(n): s = str(n); return s == s[::-1]
def nextpal(p): # next largest palindrome after palindrome p
d = str(p)
if set(d) == {'9'}: return int('1' + '0'*(len(d)-1) + '1')
h = str(int(d[:(len(d)+1)//2]) + 1)
return int(h + h[:-1][::-1]) if len(d)&1 else int(h + h[::-1])
def agen():
aset, pal, minpal = {1}, 1, 2
while True:
an = pal; yield an; aset.add(an); pal = minpal
while pal in aset or ispal(an+pal): pal = nextpal(pal)
while minpal in aset: minpal = nextpal(minpal)
print(list(islice(agen(), 55))) # Michael S. Branicky, Sep 14 2022
CROSSREFS
Cf. A002113 (palindromes), A029742 (non-palindromes), A262038 (next palindrome), A357045 (non-palindromes with palindromic sum of neighbors).
Sequence in context: A346989 A136251 A073002 * A348302 A197836 A011282
KEYWORD
nonn,base
AUTHOR
Eric Angelini and M. F. Hasler, Sep 14 2022
STATUS
approved