login

Reminder: The OEIS is hiring a new managing editor, and the application deadline is January 26.

In the binary expansion of n, decrease the length of each run of 1-bits by one.
4

%I #20 Mar 31 2024 19:04:26

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

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

%U 30,31,0,0,0,1,0,0,2,3,0,0,0,1,4,2,6,7,0,0,0

%N In the binary expansion of n, decrease the length of each run of 1-bits by one.

%C Equivalently, change bits 01 -> 0, including a 0 reckoned above the most significant 1-bit of n so change there.

%C A single 1-bit run decreases to nothing. The Fibbinary numbers (A003714) are those n with only single 1-bits so that a(n) = 0 iff n is in A003714.

%C a(n) = 1 iff n is in A213540 since those values end with bits 011 (which become 01) and otherwise have only single 1-bits, as do the Fibbinary numbers.

%C Decreasing each run is the inverse of the increase A175048 so that a(A175048(k)) = k. This n = A175048(k) is the smallest n with a(n) = k and then other occurrences of k are by inserting single 1-bits into this n, including anywhere above the most significant bit.

%H Kevin Ryde, <a href="/A348710/b348710.txt">Table of n, a(n) for n = 0..10000</a>

%H <a href="/index/Bi#binary">Index entries for sequences related to binary expansion of n</a>

%e n = 14551 = binary 111 000 11 0 1 0 111

%e a(n) = 787 = binary 11 000 1 0 0 11

%t Table[FromDigits[Flatten[Split@IntegerDigits[n,2]/. {1,a___}:>{a}],2],{n,0,82}] (* _Giorgos Kalogeropoulos_, Nov 01 2021 *)

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

%o (Python)

%o def a(n): return int(bin(n).replace("b", "").replace("01", "0"), 2)

%o print([a(n) for n in range(83)]) # _Michael S. Branicky_, Oct 31 2021

%Y Cf. A007088 (binary), A175048 (increase 1-bits), A090077 (decrease to single 1-bits).

%Y Cf. A003714 (indices of 0's), A213540 (indices of 1's).

%Y Cf. A106151 (decrease 0-bits), A318921 (decrease each run).

%K base,easy,nonn

%O 0,7

%A _Kevin Ryde_, Oct 30 2021