login
The OEIS Foundation is supported by donations from users of the OEIS and by a grant from the Simons Foundation.

 

Logo


Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A139351 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 e(n). 16

%I

%S 0,1,0,1,1,2,1,2,0,1,0,1,1,2,1,2,1,2,1,2,2,3,2,3,1,2,1,2,2,3,2,3,0,1,

%T 0,1,1,2,1,2,0,1,0,1,1,2,1,2,1,2,1,2,2,3,2,3,1,2,1,2,2,3,2,3,1,2,1,2,

%U 2,3,2,3,1,2,1,2,2,3,2,3,2,3,2,3,3,4,3,4,2,3,2,3,3,4,3,4,1,2,1

%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 e(n).

%C e(n)+o(n) = A000120(n), the binary weight of n.

%C a(n) is also number of 1's and 3's in 4-ary representation of n. - _Frank Ruskey_, May 02 2009

%H Reinhard Zumkeller, <a href="/A139351/b139351.txt">Table of n, a(n) for n = 0..10000</a>

%H F. T. Adams-Watters, F. 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) 09.5.6

%H N. J. A. Sloane, <a href="/A139351/a139351.f.txt">Fortran program for this and related sequences</a>

%F a(n) + A139352(n) = A000120(n).

%F G.f.: (1/(1-z))*Sum_{m>=0} (z^(4^m)/(1+z^(4^m))). - _Frank Ruskey_, May 03 2009

%F Recurrence relation: a(0)=0, a(4m) = a(4m+2) = a(m), a(4m+1) = a(4m+3) = 1+a(m). - _Frank Ruskey_, May 11 2009

%F a(n) = Sum_{k} A030308(n,k)*A059841(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.

%p A139351 := proc(n)

%p local a,bdgs,r;

%p a := 0 ;

%p bdgs := convert(n,base,2) ;

%p for r from 1 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 terms = 99; s = (1/(1-z))*Sum[z^(4^m)/(1+z^(4^m)), {m, 0, Log[4, terms] // Ceiling}] + O[z]^terms; CoefficientList[s, z] (* _Jean-François Alcover_, Jul 21 2017 *)

%o (Fortran) See Sloane link.

%o (Haskell)

%o import Data.List (unfoldr)

%o a139351 = sum . map (`mod` 2) .

%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%2 \\ _Charles R Greathouse IV_, Apr 21 2016

%Y Cf. A000120, A139352-A139355, A039004, A139370-A139373.

%K nonn,easy

%O 0,6

%A _Nadia Heninger_ and _N. J. A. Sloane_, Jun 07 2008

%E Typo in example fixed by _Reinhard Zumkeller_, Apr 22 2011

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recent
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified March 2 05:06 EST 2021. Contains 341741 sequences. (Running on oeis4.)