%I #65 Sep 12 2023 12:02:09
%S 1,1,2,1,1,2,2,4,4,1,1,2,1,1,2,2,4,4,2,4,4,5,5,8,5,5,9,1,1,2,1,1,2,2,
%T 4,4,1,1,2,1,1,2,2,4,4,2,4,4,5,5,8,5,5,9,2,4,4,5,5,10,5,5,10,10,11,13,
%U 10,11,10,11,13,10,10,12,13,10,13,11,12,20,11,1,1,2,1,1,2,2,4,4,1,1,2,1,1,2,2,4,4,2
%N Lexicographically earliest sequence of positive integers without triples in weakly increasing arithmetic progression.
%C Formal definition: lexicographically earliest sequence of positive integers a(n) such that for any i > 0, there is no n > 0 such that 2a(n+i) = a(n) + a(n+2i) AND a(n) <= a(n+i) <= a(n+2i).
%C Sequence suggested by _Richard Stanley_ as a variant of A229037. They differ from the 55th term. The numbers n for which a(n) = 1 are given by A003278, or equally by A005836 (_Richard Stanley_).
%C The sequence defined by c(n) = 1 if a(n) = 1 and otherwise c(n) = 0 is A039966 (although with a different offset). - _N. J. A. Sloane_, Dec 01 2019
%C Pleasant to listen to (button above) with Instrument no. 13: Marimba (and for better listening, save and convert to MP3).
%H Sébastien Palcoux, <a href="/A309890/b309890.txt">Table of n, a(n) for n = 1..100000</a>
%H Sébastien Palcoux, <a href="https://mathoverflow.net/q/338415">On the first sequence without triple in arithmetic progression</a> (version: 2019-08-21), second part, MathOverflow
%H Sébastien Palcoux, <a href="/A309890/a309890.txt">Table of n, a(n) for n = 1..1000000</a>
%H Sébastien Palcoux, <a href="/A309890/a309890.png">Density plot of the first 1000000 terms</a>
%o (SageMath)
%o # %attach SAGE/ThreeFree.spyx
%o from sage.all import *
%o cpdef ThreeFree(int n):
%o cdef int i,j,k,s,Li,Lj
%o cdef list L,Lb
%o cdef set b
%o L=[1,1]
%o for k in range(2,n):
%o b=set()
%o for i in range(k):
%o if 2*((i+k)/2)==i+k:
%o j=(i+k)/2
%o Li,Lj=L[i],L[j]
%o s=2*Lj-Li
%o if s>0 and Li<=Lj:
%o b.add(s)
%o if 1 not in b:
%o L.append(1)
%o else:
%o Lb=list(b)
%o Lb.sort()
%o for t in Lb:
%o if t+1 not in b:
%o L.append(t+1)
%o break
%o return L
%o (Python)
%o from itertools import count, islice
%o def A309890_gen(): # generator of terms
%o blist = []
%o for n in count(0):
%o i, j, b = 1, 1, set()
%o while n-(i<<1) >= 0:
%o x, y = blist[n-2*i], blist[n-i]
%o z = (y<<1)-x
%o if x<=y<=z:
%o b.add(z)
%o while j in b:
%o j += 1
%o i += 1
%o blist.append(j)
%o yield j
%o A309890_list = list(islice(A309890_gen(),30)) # _Chai Wah Wu_, Sep 12 2023
%Y Cf. A003278, A005836, A039966, A229037.
%K nonn,look,easy,hear
%O 1,3
%A _Sébastien Palcoux_, Aug 21 2019