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!)
A049502 Major index of n, 2nd definition. 10
0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 2, 2, 0, 1, 0, 0, 0, 1, 2, 2, 3, 4, 3, 3, 0, 1, 2, 2, 0, 1, 0, 0, 0, 1, 2, 2, 3, 4, 3, 3, 4, 5, 6, 6, 4, 5, 4, 4, 0, 1, 2, 2, 3, 4, 3, 3, 0, 1, 2, 2, 0, 1, 0, 0, 0, 1, 2, 2, 3, 4, 3, 3, 4, 5, 6, 6, 4, 5, 4, 4, 5, 6, 7, 7, 8, 9, 8, 8, 5, 6, 7, 7, 5, 6, 5, 5, 0, 1, 2, 2, 3, 4, 3, 3, 4 (list; graph; refs; listen; history; text; internal format)
OFFSET
0,11
COMMENTS
a(A023758(n)) = 0; a(A101082(n)) > 0. - Reinhard Zumkeller, Jun 17 2015
REFERENCES
D. M. Bressoud, Proofs and Confirmations, Camb. Univ. Press, 1999; cf. p. 89.
LINKS
FORMULA
Write n in binary; add positions where there are 1's followed by 0's, counting from right.
EXAMPLE
83 = 1010011 has 1's followed by 0's in positions 2 and 5 (reading from the right), so a(83)=7.
MAPLE
A049502 := proc(n)
local a, ndgs, p ;
a := 0 ;
ndgs := convert(n, base, 2) ;
for p from 1 to nops(ndgs)-1 do
if op(p, ndgs)- op(p+1, ndgs) = 1 then
a := a+p ;
end if;
end do:
a ;
end proc: # R. J. Mathar, Oct 17 2012
MATHEMATICA
Table[Total[Flatten[Position[Partition[Reverse[IntegerDigits[n, 2]], 2, 1], _?(#=={1, 0}&)]]], {n, 0, 110}] (* Harvey P. Dale, Oct 05 2013 *)
Table[Total[SequencePosition[Reverse[IntegerDigits[n, 2]], {1, 0}][[All, 1]]], {n, 0, 120}] (* Requires Mathematica version 10 or later *) (* Harvey P. Dale, Nov 26 2020 *)
PROG
(Haskell)
a049502 = f 0 1 where
f m i x = if x <= 4
then m else f (if mod x 4 == 1
then m + i else m) (i + 1) $ div x 2
-- Reinhard Zumkeller, Jun 17 2015
(Python)
def m(n):
x=bin(int(n))[2:][::-1]
s=0
for i in range(1, len(x)):
if x[i-1]=="1" and x[i]=="0":
s+=i
return s
for i in range(101):
print(str(i)+" "+str(m(i))) # Indranil Ghosh, Dec 22 2016
(PARI) a(n)=if(n<5, return(0)); sum(i=0, exponent(n)-1, (bittest(n, i) && !bittest(n, i+1))*(i+1)) \\ Charles R Greathouse IV, Jan 30 2023
CROSSREFS
Sequence in context: A004586 A116511 A248211 * A242284 A333624 A306595
KEYWORD
nonn,base,nice,easy
AUTHOR
EXTENSIONS
More terms from Erich Friedman, Feb 19 2000
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 18 18:58 EDT 2024. Contains 371781 sequences. (Running on oeis4.)