A348710 In the binary expansion of n, decrease the length of each run of 1-bits by one.
0, 0, 0, 1, 0, 0, 2, 3, 0, 0, 0, 1, 4, 2, 6, 7, 0, 0, 0, 1, 0, 0, 2, 3, 8, 4, 4, 5, 12, 6, 14, 15, 0, 0, 0, 1, 0, 0, 2, 3, 0, 0, 0, 1, 4, 2, 6, 7, 16, 8, 8, 9, 8, 4, 10, 11, 24, 12, 12, 13, 28, 14, 30, 31, 0, 0, 0, 1, 0, 0, 2, 3, 0, 0, 0, 1, 4, 2, 6, 7, 0, 0, 0
Offset: 0
Examples
n = 14551 = binary 111 000 11 0 1 0 111 a(n) = 787 = binary 11 000 1 0 0 11
Links
Crossrefs
Programs
-
Mathematica
Table[FromDigits[Flatten[Split@IntegerDigits[n,2]/. {1,a___}:>{a}],2],{n,0,82}] (* Giorgos Kalogeropoulos, Nov 01 2021 *)
-
PARI
a(n) = my(v=binary(n),t=0); for(i=2,#v, if(v[i-1]||!v[i], v[t++]=v[i])); fromdigits(v[1..t],2);
-
Python
def a(n): return int(bin(n).replace("b", "").replace("01", "0"), 2) print([a(n) for n in range(83)]) # Michael S. Branicky, Oct 31 2021
Comments