login
A383976
In the binary expansion of n, expand bits 1 -> 11 and 0 -> 10.
0
2, 3, 14, 15, 58, 59, 62, 63, 234, 235, 238, 239, 250, 251, 254, 255, 938, 939, 942, 943, 954, 955, 958, 959, 1002, 1003, 1006, 1007, 1018, 1019, 1022, 1023, 3754, 3755, 3758, 3759, 3770, 3771, 3774, 3775, 3818, 3819, 3822, 3823, 3834, 3835, 3838, 3839, 4010, 4011, 4014
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.
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
Sequence in context: A260143 A353871 A275303 * A281500 A041009 A042367
KEYWORD
nonn,base,easy
AUTHOR
Darío Clavijo, May 16 2025
STATUS
approved