login
A266727
Stanley sequence S(0,1,7).
3
0, 1, 7, 8, 10, 11, 17, 18, 30, 31, 37, 38, 40, 41, 47, 48, 90, 91, 97, 98, 100, 101, 107, 108, 120, 121, 127, 128, 130, 131, 137, 138, 270, 271, 277, 278, 280, 281, 287, 288, 300, 301, 307, 308, 310, 311, 317, 318, 360, 361, 367, 368, 370, 371, 377, 378, 390
OFFSET
0,3
COMMENTS
Lexicographic first increasing sequence starting (0, 1, 7, ...) and such that no 3 terms are in arithmetic progression. - M. F. Hasler, Jan 18 2016
LINKS
R. A. Moy and D. Rolnick, Novel structures in Stanley sequences, arXiv:1502.06013 [math.CO], 2015.
R. A. Moy and D. Rolnick, Novel structures in Stanley sequences, Discrete Math., 339 (2016), 689-698.
A. M. Odlyzko and R. P. Stanley, Some curious sequences constructed with the greedy algorithm, 1978.
EXAMPLE
a(3) = 8 because no 3 terms among (0,1,7,8) are in AP. a(4) is not 9 because (7,8,9) would be an AP, which is excluded. a(4) = 10 works, a(5) = 11 also.
For a(6), 12 is forbidden because of (8,10,12), 13 because of (7,10,13), 14 because of (8,11,14), 15 because of (7,11,15), 16 because of (0,8,16), thus a(6) = 17 is the smallest possible choice. - M. F. Hasler, Jan 18 2016
MATHEMATICA
s = {0, 1, 7};
next[] := For[k = Last[s]+1; AppendTo[s, 0]; , True, k++, s[[-1]] = k; sp = SequencePosition[s, {___, a_, ___, b_, ___, c_, ___} /; b-a == c-b, 1]; If[sp == {}, Print[k]; Break[]]];
Do[next[], {60}];
s (* Jean-François Alcover, Oct 04 2018 *)
PROG
(Python)
A266727_list = [0, 1, 7]
for i in range(1000):
n, flag = A266727_list[-1]+1, False
while True:
for j in range(i+2, 0, -1):
m = 2*A266727_list[j]-n
if m in A266727_list:
break
if m < A266727_list[0]:
flag = True
break
else:
A266727_list.append(n)
break
if flag:
A266727_list.append(n)
break
n += 1 # Chai Wah Wu, Jan 05 2016
(PARI) A266727(n, show=1, L=3, v=[0, 1, 7], D=v->v[2..-1]-v[1..-2])={while(#v<=n, show&&print1(v[#v]", "); v=concat(v, v[#v]); while(v[#v]++, forvec(i=vector(L, j, [if(j<L, j, #v), #v]), #Set(D(vecextract(v, i)))>1||next(2), 2); break)); if(type(show)=="t_VEC", v, v[n+1])} \\ 2nd (optional) arg: zero = silent, nonzero = verbose, vector (e.g. [] or [1]) = get the whole list [a(0..n)] as return value, else just a(n). - M. F. Hasler, Jan 18 2016
CROSSREFS
KEYWORD
nonn
AUTHOR
N. J. A. Sloane, Jan 04 2016
STATUS
approved