This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.
%I A375156 #70 Aug 20 2024 16:02:53 %S A375156 2,1,4,5,18,17,20,21,74,73,68,69,82,81,84,85,298,297,292,293,274,273, %T A375156 276,277,330,329,324,325,338,337,340,341,1194,1193,1188,1189,1170, %U A375156 1169,1172,1173,1098,1097,1092,1093,1106,1105,1108,1109,1322,1321,1316,1317,1298,1297,1300 %N 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. %C A375156 At the first bit of n, the previous bit is considered to be 0. %C A375156 n=0 is a single 0 bit. %C A375156 Equivalently for n >= 1, between adjacent bits u,v of n, insert bit u NOR v. %C A375156 This is essentially the MFM(1,3) RLL binary encoding, without leading zeros. %C A375156 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 %H A375156 Paolo Xausa, <a href="/A375156/b375156.txt">Table of n, a(n) for n = 0..10000</a> %H A375156 Wikipedia, <a href="https://en.wikipedia.org/wiki/Run-length_limited">Run-length limited</a>. %F A375156 a(n) = a(n-1) - (-1)^floor(n/2) for n odd. %F A375156 a(n) mod 2 = 0 for n even. %F A375156 a(n) = A374625(n) AND a(n) where AND is the bitwise-and. %F A375156 a(n) OR A374625(n) = A374625(n) where OR is the bitwise-or. %e A375156 For n=137, %e A375156 n = binary 1 0 0 0 1 0 0 1 %e A375156 a(n) = binary 01 00 10 10 01 00 10 01 = 19017 %t A375156 A375156[n_] := FromDigits[StringReplace[IntegerString[n, 2], {"10" -> "0100", "1" -> "01", "0" -> "10"}], 2]; Array[A375156,100,0] (* _Paolo Xausa_, Aug 19 2024 *) %o A375156 (Python) %o A375156 def mfm_encode(data): %o A375156 prev_enc_bit, enc = "0", "" %o A375156 for i in range(len(data)): %o A375156 enc += ("1" if data[i] == "0" and prev_enc_bit == "0" else "0") %o A375156 enc += data[i] %o A375156 prev_enc_bit = enc[-1] %o A375156 return enc %o A375156 def a(n): %o A375156 enc = mfm_encode(bin(n)[2:]) %o A375156 return int("".join(map(str, enc)), 2) %o A375156 print([a(n) for n in range(0, 55)]) %o A375156 (PARI) %o A375156 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; %o A375156 a(n)=if(n==0,return(2));fromdigits(mfm_encode(binary(n)),2); %o A375156 vector(55,n,a(n-1)) %Y A375156 Cf. A008836, A057077, A374625. %K A375156 nonn,base %O A375156 0,1 %A A375156 _DarĂo Clavijo_, Aug 01 2024