[go: up one dir, main page]

login

Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).

A306835
a(0) = 0, a(1) = 1. For k > 1, k is inserted in the sequence between the last pair of consecutive terms already in the sequence which sum to k; if no such pair exists, k is added at the end of the sequence.
2
0, 1, 4, 3, 5, 7, 16, 9, 11, 24, 13, 15, 17, 19, 40, 21, 23, 25, 27, 29, 31, 64, 33, 35, 37, 76, 39, 41, 43, 88, 45, 47, 96, 49, 100, 51, 53, 55, 112, 57, 59, 61, 124, 63, 65, 67, 136, 69, 71, 73, 148, 75, 77, 79, 160, 81, 83, 85, 172, 87, 89
OFFSET
0,3
LINKS
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
Sequence in context: A171021 A035427 A257120 * A033546 A236360 A299323
KEYWORD
nonn,easy
AUTHOR
Jan Koornstra, Mar 12 2019
STATUS
approved