A059448 The parity of the number of zero digits when n is written in binary.
0, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0, 0, 1
Offset: 1
References
- J.-P. Allouche and J. Shallit, Automatic Sequences, Cambridge Univ. Press, 2003, p. 26, Problem 23.
Links
- Reinhard Zumkeller, Table of n, a(n) for n = 1..10000
- Jeffrey Shallit, Arseny M. Shur, and Stefan Zorcic, New constructions for 3-free and 3+-free binary morphisms, arXiv:2310.15064 [math.CO], 2023. Mentions this sequence.
- Index entries for sequences related to binary expansion of n
- Index entries for characteristic functions
Crossrefs
Programs
-
Haskell
a059448 = (`mod` 2) . a023416 -- Reinhard Zumkeller, Mar 01 2012
-
Maple
s1:=[]; for n from 1 to 200 do t1:=convert(n,base,2); t2:=subs(1=NULL,t1); s1:=[op(s1),nops(t2) mod 2]; od: s1;
-
Mathematica
Table[Boole[OddQ[Count[IntegerDigits[n, 2], 0]]], {n, 1, 105}] (* Jean-François Alcover, Apr 05 2013 *)
-
PARI
a(n)=(#binary(n)-hammingweight(n))%2; vector(99,n,a(n)) /* Joerg Arndt, Sep 11 2020 */
-
Python
def A059448(n): return (n.bit_length()^n.bit_count())&1 # Chai Wah Wu, Jul 26 2023
Formula
a(2n) = 1 - a(n); a(2n+1) = a(n) = 1 - a(2n). If 2^k <= n < 2^(k+1) then a(n) = 1 - a(n-2^(k-1)). a(n) = A023416(n) mod 2 = A059009(n) - 2n = 2n + 1 - A059010(n) = |A010060(n) - A030300(n-1)|.
Let b(1)=1 and b(n) = b(n-ceiling(n/2)) - b(n-floor(n/2)); then for n >= 1, a(n) = (1/2)*(1-b(2n+1)). - Benoit Cloitre, Apr 26 2005
Alternatively, if x is the sequence, then x = 010 mu^2(x), where mu is the Thue-Morse morphism sending 0 to 01 and 1 to 10. - Jeffrey Shallit, Jun 06 2016
Alternatively, if x is the sequence, then x = 0 tau(x), where tau is the "twisted" Thue-Morse morphism sending 0 to 10 and 1 to 01. Note that tau^2 = mu^2, giving x = 010 mu^2(x). - Michel Dekking, Sep 30 2020
Extensions
Name changed by Michel Dekking, Sep 11 2020
Comments