A160382 Number of 2's in base-4 representation of n.
0, 0, 1, 0, 0, 0, 1, 0, 1, 1, 2, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 1, 2, 1, 0, 0, 1, 0, 1, 1, 2, 1, 1, 1, 2, 1, 2, 2, 3, 2, 1, 1, 2, 1, 0, 0, 1, 0, 0, 0, 1, 0, 1, 1, 2, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 1, 2, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 1, 2, 1, 0, 0, 1, 0, 1, 1, 2, 1, 1, 1, 2, 1, 2
Offset: 0
Links
- Dominic McCarty, Table of n, a(n) for n = 0..10000
- Franklin T. Adams-Watters and Frank Ruskey, Generating Functions for the Digital Sum and Other Digit Counting Sequences, JIS 12 (2009) 09.5.6.
Crossrefs
Cf. A007090.
Programs
-
Mathematica
DigitCount[Range[0,110],4,2] (* Harvey P. Dale, Sep 09 2024 *)
-
PARI
a(n) = #select(x->(x==2), digits(n, 4)); \\ Michel Marcus, Mar 24 2020
Formula
Recurrence relation: a(0) = 0, a(4m+2) = 1+a(m), a(4m) = a(4m+1) = a(4m+3) = a(m).
G.f.: (1/(1-z))*Sum_{m>=0} (z^(2*4^m)*(1 - z^(4^m))/(1 - z^(4^(m+1)))).
Morphism: 0, j -> j,j,j+1,j; e.g., 0 -> 0010 -> 0010110111210010 -> ...