login
In binary expansion of n: reduce contiguous blocks of 1's to 1.
5

%I #25 Jul 28 2022 13:55:18

%S 0,1,2,1,4,5,2,1,8,9,10,5,4,5,2,1,16,17,18,9,20,21,10,5,8,9,10,5,4,5,

%T 2,1,32,33,34,17,36,37,18,9,40,41,42,21,20,21,10,5,16,17,18,9,20,21,

%U 10,5,8,9,10,5,4,5,2,1,64,65,66,33,68,69,34,17,72,73,74,37,36,37,18,9

%N In binary expansion of n: reduce contiguous blocks of 1's to 1.

%H Reinhard Zumkeller, <a href="/A090077/b090077.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>

%F a(a(n)) = a(n); a(A090078(n)) = A090078(a(n)) = A090079(n).

%F a(A003714(n)) = A003714(n); a(A004780(n)) < A004780(n); a(n) <= A179821(n); A085357(a(n)) = 1. - _Reinhard Zumkeller_, Jul 31 2010

%e 100 -> '1100100' -> [11]00[1]00 -> [1]00[1]00 -> '100100' -> 36=a(100).

%t Array[FromDigits[Flatten[Split@ IntegerDigits[#, 2] /. w_List /; First[w] == 1 -> {1}], 2] &, 80, 0] (* _Michael De Vlieger_, Jul 28 2022 *)

%o (Python)

%o def a(n):

%o b = bin(n)[2:]

%o while "11" in b: b = b.replace("11", "1")

%o return int(b, 2)

%o print([a(n) for n in range(81)]) # _Michael S. Branicky_, Jul 27 2022

%Y Cf. A007088, A090079, A090078, A348710.

%K nonn,base

%O 0,3

%A _Reinhard Zumkeller_, Nov 20 2003