login

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

Major index of n, 2nd definition.
10

%I #33 Jan 30 2023 12:44:07

%S 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,

%T 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,

%U 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

%N Major index of n, 2nd definition.

%C a(A023758(n)) = 0; a(A101082(n)) > 0. - _Reinhard Zumkeller_, Jun 17 2015

%D D. M. Bressoud, Proofs and Confirmations, Camb. Univ. Press, 1999; cf. p. 89.

%H Lars Blomberg, <a href="/A049502/b049502.txt">Table of n, a(n) for n = 0..10000</a>

%F Write n in binary; add positions where there are 1's followed by 0's, counting from right.

%e 83 = 1010011 has 1's followed by 0's in positions 2 and 5 (reading from the right), so a(83)=7.

%p A049502 := proc(n)

%p local a,ndgs,p ;

%p a := 0 ;

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

%p for p from 1 to nops(ndgs)-1 do

%p if op(p,ndgs)- op(p+1,ndgs) = 1 then

%p a := a+p ;

%p end if;

%p end do:

%p a ;

%p end proc: # _R. J. Mathar_, Oct 17 2012

%t Table[Total[Flatten[Position[Partition[Reverse[IntegerDigits[n,2]],2,1],_?(#=={1,0}&)]]],{n,0,110}] (* _Harvey P. Dale_, Oct 05 2013 *)

%t 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 *)

%o (Haskell)

%o a049502 = f 0 1 where

%o f m i x = if x <= 4

%o then m else f (if mod x 4 == 1

%o then m + i else m) (i + 1) $ div x 2

%o -- _Reinhard Zumkeller_, Jun 17 2015

%o (Python)

%o def m(n):

%o x=bin(int(n))[2:][::-1]

%o s=0

%o for i in range(1,len(x)):

%o if x[i-1]=="1" and x[i]=="0":

%o s+=i

%o return s

%o for i in range(101):

%o print(str(i)+" "+str(m(i))) # _Indranil Ghosh_, Dec 22 2016

%o (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

%Y Cf. A049501, A037800.

%Y Cf. A023758, A101082.

%K nonn,base,nice,easy

%O 0,11

%A _N. J. A. Sloane_

%E More terms from _Erich Friedman_, Feb 19 2000