A089313 Write n in binary; a(n) = number represented by second block of 1's from the right.
0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1, 1, 0, 3, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 3, 3, 3, 0, 7, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 1, 1, 0, 3, 3, 3, 3, 1, 3, 3, 0, 7, 7, 7, 0, 15, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 3, 3, 1, 7, 1, 1, 0, 3, 3, 3, 3, 1, 3, 3, 3, 1, 1, 1, 3, 3, 3, 3, 0, 7, 7, 7, 7, 1, 7, 7, 0
Offset: 0
Examples
13 = 1101 so a(13) = 3.
Links
- Robert Israel, Table of n, a(n) for n = 0..10000
Programs
-
Maple
f:= proc(n) local t,q,r; r:= 0: t:= n; while t::even do t:= t/2 od; while t::odd do t:= (t-1)/2 od; if t = 0 then return 0 fi; while t::even do t:= t/2 od; while t::odd do r:= 2*r+1; t:= (t-1)/2 od; r end proc: f(0):= 0: map(f, [$0..120]); # Robert Israel, Aug 03 2025
-
Mathematica
sb1[n_]:=With[{c=If[#[[1]]==0,Nothing,#]&/@Split[IntegerDigits[n,2]]},If[Length[c]==1,0,FromDigits[c[[-2]],2]]]; Join[{0},Table[sb1[n],{n,120}]] (* Harvey P. Dale, Aug 02 2025 *)
-
PARI
{ a(n) = local(b,l,r,c); b=binary(n); l=length(b); while(l&&b[l]==0,l--); while(l&&b[l]==1,l--); while(l&&b[l]==0,l--); r=0; c=0; while(l&&b[l],r+=2^c;l--;c++); r; } for(i=0,200,print1(a(i),", ")) \\ Lambert Klasen (Lambert.Klasen(AT)gmx.net), Sep 09 2005
Formula
a(n) = 2^A089310(n)-1. - David Wasserman, Sep 09 2005
Extensions
More terms from David Wasserman and Lambert Klasen (Lambert.Klasen(AT)gmx.net), Sep 09 2005
Corrected and extended by Harvey P. Dale, Aug 02 2025