login
The OEIS is supported by the many generous donors to the OEIS 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). 18
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, 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, 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 (list; graph; refs; listen; history; text; internal format)
OFFSET
0,6
COMMENTS
e(n)+o(n) = A000120(n), the binary weight of n.
a(n) is also number of 1's and 3's in 4-ary representation of n. - Frank Ruskey, May 02 2009
LINKS
Franklin T. Adams-Watters and Frank Ruskey, Generating Functions for the Digital Sum and Other Digit Counting Sequences, JIS 12 (2009), Article 09.5.6.
FORMULA
a(n) + A139352(n) = A000120(n).
G.f.: (1/(1-z))*Sum_{m>=0} (z^(4^m)/(1+z^(4^m))). - Frank Ruskey, May 03 2009
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
a(n) = Sum_{k} A030308(n,k)*A059841(k). - Philippe Deléham, Oct 14 2011
EXAMPLE
For n = 43 = 2^0 + 2^1 + 2^3 + 2^5, e(43)=1, o(43)=3.
MAPLE
A139351 := proc(n)
local a, bdgs, r;
a := 0 ;
bdgs := convert(n, base, 2) ;
for r from 1 to nops(bdgs) by 2 do
if op(r, bdgs) = 1 then
a := a+1 ;
end if;
end do:
a;
end proc: # R. J. Mathar, Jul 21 2016
MATHEMATICA
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 *)
a[0] = 0; a[n_] := a[n] = a[Floor[n/4]] + If[OddQ[Mod[n, 4]], 1, 0]; Array[a, 100, 0] (* Amiram Eldar, Jul 18 2023 *)
PROG
(Fortran) See Sloane link.
(Haskell)
import Data.List (unfoldr)
a139351 = sum . map (`mod` 2) .
unfoldr (\x -> if x == 0 then Nothing else Just (x, x `div` 4)
-- Reinhard Zumkeller, Apr 22 2011
(PARI) a(n)=if(n>3, a(n\4))+n%2 \\ Charles R Greathouse IV, Apr 21 2016
CROSSREFS
Sequence in context: A345021 A104886 A215604 * A285677 A036578 A229764
KEYWORD
nonn,base,easy
AUTHOR
EXTENSIONS
Typo in example fixed by Reinhard Zumkeller, Apr 22 2011
STATUS
approved

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

License Agreements, Terms of Use, Privacy Policy. .

Last modified April 17 22:23 EDT 2024. Contains 371767 sequences. (Running on oeis4.)