OFFSET
0,3
COMMENTS
The sequence is a permutation of the nonnegative integers: there is no constraint on terms a(3k) and a(3k+1), which are always the smallest nonnegative integers that did not occur earlier. Therefore each nonnegative integer will occur exactly once. - M. F. Hasler, Apr 18 2024
From M. F. Hasler, Apr 20 2024: (Start)
See A369856 for the inverse permutation.
Conjecture 1: The only fixed points of this permutation are n = 0 and 1.
Conjecture 2: For all k >= 0, a(3k+2) <= R(concatenate(a(3k), a(3k+1), 1)), where R = A004086 = reverse.
Conjecture 3: For all k >= 0, a(3k+1) - a(3k) = 1 or 2. (Verified up to k = 3333. a(3k+1) - a(3k) = 2 for k = 15, 36, 62, 81, 110, 129, 138, 163, 182, ...)
(End)
FORMULA
a(3k) = 2k + o(log k) ; a(3k) + 1 <= a(3k+1) <= a(3k) + 2 (conjectured). - M. F. Hasler, Apr 20 2024
EXAMPLE
Triples begin (0,1,10), (2,3,32), (4,5,54), (6,7,76), (8,9,98), ... where the palindromic pattern is clearly visible in each triple.
MATHEMATICA
a[0]=0; a[n_]:=a[n]=(k=1; While[MemberQ[Array[a, n-1], k]|| If[Mod[n, 3]==2, !PalindromeQ[Flatten[IntegerDigits/@Join[{a[n-2]}, {a[n-1]}, {k}]]]], k++]; k); Array[a, 100, 0]
PROG
(PARI) A371113_upto(N)={my(L, U=[-1], F=fromdigits); vector(N, n, [L, N]=[N, if(n%3, U[1]+1, L=eval(Vec(Str(L, N))); N=0; for(k=1, #L, L[k] && Vecrev(n=concat(L, Vecrev(L, k)))==n && !setsearch(U, n=F(Vecrev(L, k))) && n>U[1] && [N=n; break]); if(!N, L=Vecrev(L, -1-#L); until(!setsearch(U, N=F(L))&& N>U[1], L[1]++)); N)]; U=setunion(U, [N]); while(#U>1 && U[1]+1==U[2], U=U[^1]); N)} \\ M. F. Hasler, Apr 19 2024
(Python)
def A371113(n):
try: return A371113.terms[n]
except IndexError: pass # just need to compute more terms
while len(T := A371113.terms) <= n:
if len(T)%3 < 2:
T.append(x := A371113.least_unused)
while x+1 in T: x += 1
A371113.least_unused = x+1
else:
for i in range(1, len(suffix := (str(T[-2])+str(T[-1]))[::-1])+1):
if suffix[-i] != '0' and (s := suffix[:-i-1:-1] + suffix
)==s[::-1] and (x := int(suffix[-i:])) not in T: break
else: x = int('1'+suffix); assert x not in T
T.append(x); assert x > A371113.least_unused
return T[n] # M. F. Hasler, Apr 19 2024
CROSSREFS
KEYWORD
nonn,base
AUTHOR
Eric Angelini and Giorgos Kalogeropoulos, Apr 09 2024
STATUS
approved