OFFSET
0,2
COMMENTS
This is what would now be called the Stanley Sequence S(0,4). See A185256.
REFERENCES
R. K. Guy, Unsolved Problems in Number Theory, E10.
N. J. A. Sloane and Simon Plouffe, The Encyclopedia of Integer Sequences, Academic Press, 1995 (includes this sequence).
LINKS
Chai Wah Wu, Table of n, a(n) for n = 0..10000
P. Erdős, V. Lev, G. Rauzy, C. Sandor, and A. Sarkozy, Greedy algorithm, arithmetic progressions, subset sums and divisibility, Discrete Mathematics 200 (1999), pp. 119-135.
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.
MATHEMATICA
ss[s1_, M_] := Module[{n, chvec, swi, p, s2, i, j, t1, mmm}, t1 = Length[s1]; mmm = 1000; s2 = Table[s1, {t1 + M}] // Flatten; chvec = Array[0&, mmm]; For[i = 1 , i <= t1 , i++, chvec[[s2[[i]] ]] = 1]; (* get n-th term *) For[n = t1+1 , n <= t1 + M , n++, (* try i as next term *) For[i = s2[[n-1]] + 1 , i <= mmm , i++, swi = -1; (* test against j-th term *) For[ j = 1 , j <= n-2 , j++, p = s2[[n - j]]; If[ 2*p - i < 0 , Break[] ]; If[ chvec[[2*p - i]] == 1 , swi = 1; Break[] ] ]; If[ swi == -1 , s2[[n]] = i; chvec[[i]] = 1; Break[] ] ]; If[ swi == 1 , Print["Error, no solution at n = ", n] ] ]; Table[s2[[i]], {i, 1, t1+M}] ]; ss[{0, 4}, 80] (* Jean-François Alcover, Sep 10 2013, translated from Maple program given in A185256 *)
PROG
(Python)
A005487_list = [0, 4]
for i in range(101-2):
n, flag = A005487_list[-1]+1, False
while True:
for j in range(i+1, 0, -1):
m = 2*A005487_list[j]-n
if m in A005487_list:
break
if m < A005487_list[0]:
flag = True
break
else:
A005487_list.append(n)
break
if flag:
A005487_list.append(n)
break
n += 1 # Chai Wah Wu, Jan 05 2016
CROSSREFS
KEYWORD
nonn,nice
AUTHOR
EXTENSIONS
Name clarified by Charles R Greathouse IV, Jan 30 2014
STATUS
approved