cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

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

This page as a plain text file.
%I A139352 #44 Dec 19 2024 11:41:30
%S A139352 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 A139352 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 A139352 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 A139352 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 A139352 e(n) + o(n) = A000120(n), the binary weight of n.
%C A139352 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 A139352 Reinhard Zumkeller, <a href="/A139352/b139352.txt">Table of n, a(n) for n = 0..10000</a>
%H A139352 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 A139352 G.f.: (1/(1-z))*Sum_{m>=0} (z^(2*4^m)/(1+(2*4^m))). - _Frank Ruskey_, May 03 2009
%F A139352 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 A139352 a(n) = Sum_{k} A030308(n,k)*A000035(k). - _Philippe Deléham_, Oct 14 2011
%e A139352 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 A139352 := proc(n)
%p A139352     local a,bdgs,r;
%p A139352     a := 0 ;
%p A139352     bdgs := convert(n,base,2) ;
%p A139352     for r from 2 to nops(bdgs) by 2 do
%p A139352         if op(r,bdgs) = 1 then
%p A139352             a := a+1 ;
%p A139352         end if;
%p A139352     end do:
%p A139352     a;
%p A139352 end proc: # _R. J. Mathar_, Jul 21 2016
%t A139352 a[n_] := Count[Position[Reverse@IntegerDigits[n, 2], 1]-1, {_?OddQ}];
%t A139352 Table[a[n], {n, 0, 99}] (* _Jean-François Alcover_, Mar 04 2023 *)
%t A139352 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 A139352 (Fortran) c See link in A139351
%o A139352 (Haskell)
%o A139352 import Data.List (unfoldr)
%o A139352 a139352 = sum . map ((`div` 2) . (`mod` 4)) .
%o A139352    unfoldr (\x -> if x == 0 then Nothing else Just (x, x `div` 4))
%o A139352 -- _Reinhard Zumkeller_, Apr 22 2011
%o A139352 (PARI) a(n)=if(n>3,a(n\4))+n%4\2 \\ _Charles R Greathouse IV_, Apr 21 2016
%Y A139352 Cf. A000035, A000120, A030308, A039004, A139351, A139353, A139354, A139355, A139370, A139371, A139372, A139373.
%K A139352 nonn,base,easy
%O A139352 0,11
%A A139352 _Nadia Heninger_ and _N. J. A. Sloane_, Jun 07 2008