OFFSET
0,1
COMMENTS
This is essentially the differential Manchester encoding or FM:(0,1) RLL.
Terms come in groups of two and all terms have even bitsize.
In this case, by convention, 0 is treated as a single 0 bit and leading zeros in other terms are omitted.
LINKS
Wikipedia, Run-length limited
FORMULA
a(n) = a(n-1) + 1 for n odd.
a(n) = 2 + (n mod 2) + 4*a(floor(n/2)) if n >= 2 else 2 + (n mod 2).
a(n) = Sum_{k=0..floor(log_2(n))} 4^k*(2+b_k), where b_k is the k-th bit of n.
MAPLE
a:= n-> 2+(n mod 2)+`if`(n<2, 0, 4*a(iquo(n, 2))):
seq(a(n), n=0..50); # Alois P. Heinz, May 16 2025
MATHEMATICA
a[n_] := a[n] = 2 + Mod[n, 2] + If[n < 2, 0, 4*a[Floor[n/2]]]; Array[a, 51, 0] (* Shenghui Yang, May 21 2025 *)
PROG
(Python)
a = lambda n: int(bin(n)[2:].replace('1', '3').replace('0', '2'), 4)
print([a(n) for n in range(0, 51)])
CROSSREFS
KEYWORD
nonn,base,easy
AUTHOR
Darío Clavijo, May 16 2025
STATUS
approved
