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”).

n-th run has length 2^(n-1).
8

%I #38 Apr 12 2023 10:07:52

%S 0,1,1,0,0,0,0,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,

%T 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,

%U 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0

%N n-th run has length 2^(n-1).

%H Antti Karttunen, <a href="/A030301/b030301.txt">Table of n, a(n) for n = 1..65537</a>

%H <a href="/index/Bi#binary">Index entries for sequences related to binary expansion of n</a>

%H <a href="/index/Ch#char_fns">Index entries for characteristic functions</a>

%F a(n) = A000523(n) mod 2 = (A029837(n+1)+1) mod 2.

%F a(n) = 0 iff n has an odd number of digits in binary, = 1 otherwise. - _Henry Bottomley_, Apr 06 2000

%F a(n) = (1/2)*{1-(-1)^floor(log(n)/log(2))}. - _Benoit Cloitre_, Nov 22 2001

%F a(n) = 1-a(floor(n/2)). - _Vladeta Jovovic_, Aug 04 2003

%F a(n) = 1 - A030300(n). - _Antti Karttunen_, Oct 10 2017

%t nMax = 7; Table[1 - Mod[n, 2], {n, nMax}, {2^(n-1)}] // Flatten (* _Jean-François Alcover_, Oct 20 2016 *)

%t Table[{PadRight[{},2^(n-1),0],PadRight[{},2^n,1]},{n,1,8,2}]//Flatten (* _Harvey P. Dale_, Apr 12 2023 *)

%o (PARI) a(n)=if(n<1,0,1-length(binary(n))%2)

%o (PARI) a(n)=if(n<1,0,if(n%2==0,-a(n/2)+1,-a((n-1)/2)+1-(((n-1)/2)==0))) /* _Ralf Stephan_ */

%o (Magma) [Floor(Log(n)/Log(2)) mod 2: n in [1..100]]; // _Vincenzo Librandi_, Jun 23 2015

%o (Python)

%o def A030301(n): return n.bit_length()&1^1 # _Chai Wah Wu_, Jan 30 2023

%Y Cf. A000523, A029837.

%Y Cf. A030300. Partial sums give A079954.

%Y Characteristic function of A053754 (after its initial 0).

%K nonn,base,easy

%O 1,1

%A _Jean-Paul Delahaye_