login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
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

%I #19 Mar 31 2019 07:18:01

%S 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,

%T 76,39,41,43,88,45,47,96,49,100,51,53,55,112,57,59,61,124,63,65,67,

%U 136,69,71,73,148,75,77,79,160,81,83,85,172,87,89

%N 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.

%H Jan Koornstra, <a href="/A306835/b306835.txt">Table of n, a(n) for n = 0..10000</a>

%H David A. Corneth, <a href="/A306835/a306835.gp.txt">PARI program</a>

%e The first iterations of the sequence are as follows:

%e [0, 1];

%e [0, 1, 2];

%e [0, 1, 3, 2], since 1 + 2 = 3;

%e [0, 1, 4, 3, 2], since 1 + 3 = 4;

%e [0, 1, 4, 3, 5, 2], since 3 + 2 = 5 (and appears later in the sequence than 1 + 4);

%e [0, 1, 4, 3, 5, 2, 6].

%t 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 *)

%o (Python3)

%o seq = [0, 1]

%o for n in range(2, 281):

%o for k in range(len(seq) - 1, 0, -1):

%o if seq[k] + seq[k - 1] == n:

%o seq.insert(k, n)

%o break

%o else: seq += [n]

%o print(seq[:100])

%o (PARI) See Corneth link \\ _David A. Corneth_, Mar 24 2019

%K nonn,easy

%O 0,3

%A _Jan Koornstra_, Mar 12 2019

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified September 16 23:59 EDT 2024. Contains 375984 sequences. (Running on oeis4.)