OFFSET
0,1
COMMENTS
At the first bit of n, the previous bit is considered to be 0.
n=0 is a single 0 bit.
Equivalently for n >= 1, between adjacent bits u,v of n, insert bit u NOR v.
This is essentially the MFM(1,3) RLL binary encoding, without leading zeros.
Equivalently, apply (from left to right, in the given order) the following transformations to the binary expansion of n: 10 -> 0100, 1 -> 01, 0 -> 10. - Paolo Xausa, Aug 19 2024
LINKS
Paolo Xausa, Table of n, a(n) for n = 0..10000
Wikipedia, Run-length limited.
FORMULA
EXAMPLE
For n=137,
n = binary 1 0 0 0 1 0 0 1
a(n) = binary 01 00 10 10 01 00 10 01 = 19017
MATHEMATICA
A375156[n_] := FromDigits[StringReplace[IntegerString[n, 2], {"10" -> "0100", "1" -> "01", "0" -> "10"}], 2]; Array[A375156, 100, 0] (* Paolo Xausa, Aug 19 2024 *)
PROG
(Python)
def mfm_encode(data):
prev_enc_bit, enc = "0", ""
for i in range(len(data)):
enc += ("1" if data[i] == "0" and prev_enc_bit == "0" else "0")
enc += data[i]
prev_enc_bit = enc[-1]
return enc
def a(n):
enc = mfm_encode(bin(n)[2:])
return int("".join(map(str, enc)), 2)
print([a(n) for n in range(0, 55)])
(PARI)
mfm_encode(data)=prev_enc_bit=0; enc=[]; for(i=1, #data, enc=concat(enc, (1-data[i])*(1-prev_enc_bit)); enc=concat(enc, data[i]); prev_enc_bit=data[i]; ); enc;
a(n)=if(n==0, return(2)); fromdigits(mfm_encode(binary(n)), 2);
vector(55, n, a(n-1))
CROSSREFS
KEYWORD
nonn,base
AUTHOR
Darío Clavijo, Aug 01 2024
STATUS
approved