OFFSET
0,3
LINKS
Jan Koornstra, Table of n, a(n) for n = 0..10000
David A. Corneth, PARI program
EXAMPLE
The first iterations of the sequence are as follows:
[0, 1];
[0, 1, 2];
[0, 1, 3, 2], since 1 + 2 = 3;
[0, 1, 4, 3, 2], since 1 + 3 = 4;
[0, 1, 4, 3, 5, 2], since 3 + 2 = 5 (and appears later in the sequence than 1 + 4);
[0, 1, 4, 3, 5, 2, 6].
MATHEMATICA
With[{nn = 270}, TakeWhile[Partition[Nest[Function[{a, n}, If[Length@ # == 0, Append[a, n], Insert[a, n, 1 + #[[-1, 1]] ]] &@ Position[Total /@ Partition[a, 2, 1], n] ] @@ {#, Length@ #} &, {0}, nn], 2, 1], Total@ # < nn &]][[All, 1]] (* Michael De Vlieger, Mar 24 2019 *)
PROG
(Python3)
seq = [0, 1]
for n in range(2, 281):
for k in range(len(seq) - 1, 0, -1):
if seq[k] + seq[k - 1] == n:
seq.insert(k, n)
break
else: seq += [n]
print(seq[:100])
(PARI) See Corneth link \\ David A. Corneth, Mar 24 2019
CROSSREFS
KEYWORD
nonn,easy
AUTHOR
Jan Koornstra, Mar 12 2019
STATUS
approved