login
Guy Steele's sequence GS(4,6) (see A135416).
7

%I #12 Oct 17 2016 19:43:09

%S 1,2,3,3,5,4,7,4,7,6,11,5,9,8,15,5,9,8,15,7,13,12,23,6,11,10,19,9,17,

%T 16,31,6,11,10,19,9,17,16,31,8,15,14,27,13,25,24,47,7,13,12,23,11,21,

%U 20,39,10,19,18,35,17,33,32,63,7,13,12,23,11,21,20,39,10,19,18,35,17,33,32,63

%N Guy Steele's sequence GS(4,6) (see A135416).

%H G. C. Greubel, <a href="/A135533/b135533.txt">Table of n, a(n) for n = 1..1000</a>

%F From _Don Knuth_, Mar 01 2008: (Start)

%F a(n) = Sum_{k=0..A000523(n)} 2^A000120(n mod 2^k).

%F a(n) = 1 + A000523(n) * 2^A000120(n) - A135586(n). (End)

%p GS(4,6,200); [see A135416].

%t i = 4; j = 6; Clear[a]; a[1] = 1; a[n_?EvenQ] := a[n] = {0, 1, a[n/2], a[n/2]+1, 2*a[n/2], 2*a[n/2]+1}[[i]]; a[n_?OddQ] := a[n] = {0, 1, a[(n-1)/2], a[(n-1)/2]+1, 2*a[(n-1)/2], 2*a[(n-1)/2]+1}[[j]]; Array[a, 79] (* _Jean-François Alcover_, Sep 12 2013 *)

%o (PARI) a(n)=if(n<4, return(n)); (1+n%2)*a(n\2) + 1 \\ _Charles R Greathouse IV_, Oct 17 2016

%Y Cf. A135416.

%K nonn,easy

%O 1,2

%A _N. J. A. Sloane_, based on a message from Guy Steele and _Don Knuth_, Mar 01 2008