login
a(2n+1) = a(2n) + a(2n-1), a(2n)=least number not yet in the sequence, a(1)=1.
9

%I #22 Dec 02 2021 07:33:41

%S 0,1,2,3,4,7,5,12,6,18,8,26,9,35,10,45,11,56,13,69,14,83,15,98,16,114,

%T 17,131,19,150,20,170,21,191,22,213,23,236,24,260,25,285,27,312,28,

%U 340,29,369,30,399,31,430,32,462,33,495,34,529,36,565,37,602,38,640,39,679

%N a(2n+1) = a(2n) + a(2n-1), a(2n)=least number not yet in the sequence, a(1)=1.

%C Lexicographically earliest reordering of the nonnegative integers (can be extended by symmetry to a permutation of all integers) such that a(2n+1) = a(2n) + a(2n-1).

%H M. F. Hasler, <a href="/A167151/b167151.txt">Table of n, a(n) for n = 0..2000</a>

%H <a href="/index/Ho#Hofstadter">Index entries for Hofstadter-type sequences</a>

%H <a href="/index/Per#IntegerPermutation">Index entries for sequences that are permutations of the natural numbers</a>

%F a(2n-1) = A005228(n); a(2n) = A030124(n).

%t a[0] = 0; a[1] = 1;

%t a[n_?OddQ] := a[n] = a[n - 1] + a[n - 2];

%t a[n_?EvenQ] := a[n] = For[k = 2, True, k++,

%t If[FreeQ[Array[a, n - 1], k], Return[k]]];

%t Table[a[n], {n, 0, 100}] (* _Jean-François Alcover_, Dec 02 2021 *)

%o (PARI) {used=[]; print1(b=0); a=1; for(i=1,99, used=setunion(used,Set(a+=b)); while(setsearch(used,b++), used=setminus(used,Set(b))); print1(", "a", "b))}

%o (Haskell)

%o import Data.List (transpose)

%o a167151 n = a167151_list !! n

%o a167151_list = 0 : concat (transpose [a005228_list, a030124_list])

%o -- _Reinhard Zumkeller_, May 17 2013

%Y Cf. A022941, A143344, A156031.

%Y Cf. A225850 (inverse).

%K easy,nonn

%O 0,3

%A _M. F. Hasler_, Nov 01 2009