A090078 In binary expansion of n, reduce contiguous blocks of 0's to 0.
0, 1, 2, 3, 2, 5, 6, 7, 2, 5, 10, 11, 6, 13, 14, 15, 2, 5, 10, 11, 10, 21, 22, 23, 6, 13, 26, 27, 14, 29, 30, 31, 2, 5, 10, 11, 10, 21, 22, 23, 10, 21, 42, 43, 22, 45, 46, 47, 6, 13, 26, 27, 26, 53, 54, 55, 14, 29, 58, 59, 30, 61, 62, 63, 2, 5, 10, 11, 10, 21, 22, 23, 10, 21
Offset: 0
Examples
100 -> '1100100' -> 11[00]1[00] -> 11[0]1[0] -> '11010' -> 26=a(100).
Links
Programs
-
Mathematica
a[n_] := FromDigits[Flatten[Split[IntegerDigits[n, 2]] /. x_List /; x[[1]] == 0 -> {0}], 2]; Array[a, 100, 0] (* Amiram Eldar, Jul 30 2025 *)
-
PARI
a(n)=my(v=binary(n),t); for(i=1,#v, if(v[i], t+=t+1, t%2, t+=t)); t \\ Charles R Greathouse IV, Aug 17 2016
-
Python
def a(n): b = bin(n)[2:] while "00" in b: b = b.replace("00", "0") return int(b, 2) print([a(n) for n in range(81)]) # Michael S. Branicky, Jul 27 2022