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”).
%I #44 Dec 19 2024 11:41:30
%S 0,0,1,1,0,0,1,1,1,1,2,2,1,1,2,2,0,0,1,1,0,0,1,1,1,1,2,2,1,1,2,2,1,1,
%T 2,2,1,1,2,2,2,2,3,3,2,2,3,3,1,1,2,2,1,1,2,2,2,2,3,3,2,2,3,3,0,0,1,1,
%U 0,0,1,1,1,1,2,2,1,1,2,2,0,0,1,1,0,0,1,1,1,1,2,2,1,1,2,2,1,1,2
%N Let the binary expansion of n be n = Sum_{k} 2^{r_k}, let e(n) be the number of r_k's that are even, o(n) the number that are odd; sequence gives o(n).
%C e(n) + o(n) = A000120(n), the binary weight of n.
%C a(n) is also the number of 2's and 3's in the 4-ary representation of n. - _Frank Ruskey_, May 02 2009
%H Reinhard Zumkeller, <a href="/A139352/b139352.txt">Table of n, a(n) for n = 0..10000</a>
%H Franklin T. Adams-Watters and Frank Ruskey, <a href="https://cs.uwaterloo.ca/journals/JIS/VOL12/Ruskey2/ruskey14.html">Generating Functions for the Digital Sum and Other Digit Counting Sequences</a>, JIS 12 (2009), Article 09.5.6.
%F G.f.: (1/(1-z))*Sum_{m>=0} (z^(2*4^m)/(1+(2*4^m))). - _Frank Ruskey_, May 03 2009
%F Recurrence relation: a(0)=0, a(4m) = a(4m+1) = a(m), a(4m+2) = a(4m+3) = 1+a(m). - _Frank Ruskey_, May 11 2009
%F a(n) = Sum_{k} A030308(n,k)*A000035(k). - _Philippe Deléham_, Oct 14 2011
%e For n = 43 = 2^0 + 2^1 + 2^3 + 2^5, e(43)=1, o(43)=3. [Typo fixed by _Reinhard Zumkeller_, Apr 22 2011]
%p A139352 := proc(n)
%p local a,bdgs,r;
%p a := 0 ;
%p bdgs := convert(n,base,2) ;
%p for r from 2 to nops(bdgs) by 2 do
%p if op(r,bdgs) = 1 then
%p a := a+1 ;
%p end if;
%p end do:
%p a;
%p end proc: # _R. J. Mathar_, Jul 21 2016
%t a[n_] := Count[Position[Reverse@IntegerDigits[n, 2], 1]-1, {_?OddQ}];
%t Table[a[n], {n, 0, 99}] (* _Jean-François Alcover_, Mar 04 2023 *)
%t a[0] = 0; a[n_] := a[n] = a[Floor[n/4]] + If[Mod[n, 4] > 1, 1, 0]; Array[a, 100, 0] (* _Amiram Eldar_, Jul 18 2023 *)
%o (Fortran) c See link in A139351
%o (Haskell)
%o import Data.List (unfoldr)
%o a139352 = sum . map ((`div` 2) . (`mod` 4)) .
%o unfoldr (\x -> if x == 0 then Nothing else Just (x, x `div` 4))
%o -- _Reinhard Zumkeller_, Apr 22 2011
%o (PARI) a(n)=if(n>3,a(n\4))+n%4\2 \\ _Charles R Greathouse IV_, Apr 21 2016
%Y Cf. A000035, A000120, A030308, A039004, A139351, A139353, A139354, A139355, A139370, A139371, A139372, A139373.
%K nonn,base,easy
%O 0,11
%A _Nadia Heninger_ and _N. J. A. Sloane_, Jun 07 2008