login

Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).

A375156
In the binary expansion of n: expand bits 1 -> 01 and 0 -> x0 from most to least significant, where x is the complement of the previous bit from n.
1
2, 1, 4, 5, 18, 17, 20, 21, 74, 73, 68, 69, 82, 81, 84, 85, 298, 297, 292, 293, 274, 273, 276, 277, 330, 329, 324, 325, 338, 337, 340, 341, 1194, 1193, 1188, 1189, 1170, 1169, 1172, 1173, 1098, 1097, 1092, 1093, 1106, 1105, 1108, 1109, 1322, 1321, 1316, 1317, 1298, 1297, 1300
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
FORMULA
a(n) = a(n-1) - (-1)^floor(n/2) for n odd.
a(n) mod 2 = 0 for n even.
a(n) = A374625(n) AND a(n) where AND is the bitwise-and.
a(n) OR A374625(n) = A374625(n) where OR is the bitwise-or.
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