A089311 Write n in binary; a(n) = number of 0's in rightmost block of zeros, after dropping any trailing 0's.
0, 0, 0, 0, 0, 1, 0, 0, 0, 2, 1, 1, 0, 1, 0, 0, 0, 3, 2, 2, 1, 1, 1, 1, 0, 2, 1, 1, 0, 1, 0, 0, 0, 4, 3, 3, 2, 1, 2, 2, 1, 2, 1, 1, 1, 1, 1, 1, 0, 3, 2, 2, 1, 1, 1, 1, 0, 2, 1, 1, 0, 1, 0, 0, 0, 5, 4, 4, 3, 1, 3, 3, 2, 2, 1, 1, 2, 1, 2, 2, 1, 3, 2, 2, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 0, 4, 3, 3
Offset: 0
Examples
9 = 1001 so a(9) = 2.
Links
- Harvey P. Dale, Table of n, a(n) for n = 0..1000
Programs
-
Mathematica
bd[n_]:=Module[{s=Split[IntegerDigits[n,2]]},Which[Length[s]<3,0,MemberQ[ Last[s],1],Length[s[[-2]]],True,Length[s[[-3]]]]]; Array[bd,120,0] (* Harvey P. Dale, Dec 29 2013 *)
-
PARI
a(n)=local(b,c,s):b=binary(n):c=length(b):while(!b[c],c=c-1):while(c>0&&b[c],c=c-1): if(c<=0,0,s=0:while(!b[c],c=c-1:s=s+1):s) \\ Ralf Stephan
Extensions
More terms from Ralf Stephan, Feb 01 2004