%I #40 Dec 12 2021 22:11:09
%S 0,1,2,5,8,9,10,21,32,33,34,37,40,41,42,85,128,129,130,133,136,137,
%T 138,149,160,161,162,165,168,169,170,341,512,513,514,517,520,521,522,
%U 533,544,545,546,549,552,553,554,597,640,641,642,645,648,649,650,661
%N a(n) is the smallest value of k for which A020986(k) = n.
%C Brillhart and Morton derive an omega function for the largest values of k. This sequence appears to be given by a similar alpha function.
%H Michael Day, <a href="/A212591/b212591.txt">Table of n, a(n) for n = 1..10000</a>
%H J. Brillhart and P. Morton, <a href="http://www.maa.org/programs/maa-awards/writing-awards/a-case-study-in-mathematical-research-the-golay-rudin-shapiro-sequence">A case study in mathematical research: the Golay-Rudin-Shapiro sequence</a>, Amer. Math. Monthly, 103 (1996) 854-869.
%H Kevin Ryde, <a href="http://user42.tuxfamily.org/alternate/index.html">Iterations of the Alternate Paperfolding Curve</a>, see index GRScumulFirstN.
%F a(2*n-1) - a(2*n-2) = (2^(2*k+1)+1)/3 and a(2*n) - a(2*n-1) = (2^(2*k+1)+1)/3 with a(0) = a(1) = 0, where n = (2^k)*(2*m-1) for some integers k >= 0 and m > 0.
%F Restating the formula above, a(n+1) - a(n) = A007583(A050605(n-1)) = A276391 with terms repeated. - _John Keith_, Mar 04 2021
%o (PARI)
%o alpha(n)={
%o if(n<2, return(max(0,n-1)));
%o local(nm1=n-1,
%o mi=m=ceil(nm1/2),
%o r=floor(log(m)/log(2)),
%o i,fi,alpha=0,a);
%o forstep(i=1, 2*r+1, 2,
%o mi/=2;
%o fi=(1+2^i)\3;
%o alpha+=fi*floor(0.5+mi);
%o );
%o alpha*=2;
%o if(nm1%2, \\ adjust for even n
%o a=factor(2*m)[1,2]-1;
%o alpha-= (1+2^(1+2*a))\3;
%o );
%o return(alpha);
%o }
%o (J)
%o NB. J function on a vector
%o NB. Beware round-off errors on large arguments
%o NB. ok up to ~ 1e8
%o alphav =: 3 : 0
%o n =. <: y
%o if.+/ ntlo=. n > 0 do.
%o n =. ntlo#n
%o m =. >.-: n
%o r =. <.2^.m
%o f =. <.3%~2+2^2*>:i.>./>:r
%o z =. 0
%o mi =. m
%o for_i. i.#f do.
%o z =. z + (i{f) * <.0.5 + mi =. mi%2
%o end.
%o nzer=. (+/ @: (0=>./\)@:|.)"1 @: #: m
%o ntlo #^:_1 z - (2|n) * <.-:nzer{f
%o else.
%o ntlo
%o end.
%o )
%o NB. eg alphav 1 3 5 100 2 8 33
%Y Cf. A020985, A020991, A020986.
%K nonn
%O 1,3
%A _Michael Day_, May 22 2012
%E Minor edits by _N. J. A. Sloane_, Jun 06 2012