cp's OEIS Frontend

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.

Showing 1-4 of 4 results.

A115637 In the binary expansion of n+2, transform 0->1 and 1->0 then interpret as base 4.

Original entry on oeis.org

1, 0, 5, 4, 1, 0, 21, 20, 17, 16, 5, 4, 1, 0, 85, 84, 81, 80, 69, 68, 65, 64, 21, 20, 17, 16, 5, 4, 1, 0, 341, 340, 337, 336, 325, 324, 321, 320, 277, 276, 273, 272, 261, 260, 257, 256, 85, 84, 81, 80, 69, 68, 65, 64, 21, 20, 17, 16, 5, 4, 1, 0, 1365, 1364, 1361, 1360, 1349
Offset: 0

Views

Author

Paul Barry, Jan 27 2006

Keywords

Comments

Row sums of number triangle A115636. Partial sums of A115638.
Old name was "A divide and conquer sequence".

Crossrefs

Cf. A000695, A035327, A115633, A115636, A115638 (first differences), A374625.

Programs

  • Maple
    b:= n-> 1-(n mod 2)+`if`(n<2, 0, b(iquo(n, 2))*4):
    a:= n-> b(n+2):
    seq(a(n), n=0..66);  # Alois P. Heinz, Jul 16 2024
  • Mathematica
    A115637[n_] := FromDigits[1 - IntegerDigits[n + 2, 2], 4];
    Array[A115637, 100, 0] (* Paolo Xausa, Jul 16 2024 *)
  • PARI
    up_to = 1024;
    A115633array(n, k) = (((-1)^n)*if(n==k,1, if((k+k+2)==n, -4, if((k+1)==n, -(1+(-1)^k)/2, 0))));
    A115637list(up_to) = { my(mA115633=matrix(up_to,up_to,n,k,A115633array(n-1,k-1)), mA115636 = matsolve(mA115633,matid(up_to)), v = vector(up_to)); for(n=1,up_to,v[n] = vecsum(mA115636[n,])); (v); };
    v115637 = A115637list(up_to+1);
    A115637(n) = v115637[1+n]; \\ Antti Karttunen, Nov 02 2018
    
  • PARI
    a(n) = fromdigits([!b |b<-binary(n+2)], 4); \\ Kevin Ryde, Jul 15 2024
    
  • Python
    def A115637(n): return int(bin((~(n+2))^(-1<<(n+2).bit_length()))[2:],4) # Chai Wah Wu, Jul 17 2024

Formula

G.f.: (1/(1-x))*Sum_{k>=0} 4^k*x^(2^(k+1)-2)/(1+x^(2^k)); the g.f. G(x) satisfies G(x) - 4(1+x)*x^2*G(x^2) = 1/(1-x^2).
a(n) = A000695(A035327(n+2)). - Kevin Ryde, Jul 15 2024

Extensions

New name from Kevin Ryde, Jul 15 2024

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.

Original entry on oeis.org

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

Views

Author

Darío Clavijo, Aug 01 2024

Keywords

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

Examples

			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
		

Crossrefs

Programs

  • Mathematica
    A375156[n_] := FromDigits[StringReplace[IntegerString[n, 2], {"10" -> "0100", "1" -> "01", "0" -> "10"}], 2]; Array[A375156,100,0] (* Paolo Xausa, Aug 19 2024 *)
  • 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))
  • 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)])
    

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.

A377029 a(1) = 0; thereafter in the binary expansion of a(n-1), expand bits: 1->01 and 0->10.

Original entry on oeis.org

0, 2, 6, 22, 406, 92566, 6818458006, 26055178074437806486, 540213899028732737068658940860686756246, 163551003506862550406254063077517364557434408527734307437037618419534882498966
Offset: 1

Views

Author

Darío Clavijo, Oct 13 2024

Keywords

Comments

All terms are even and leading zeros omitted in the final encoding.
Conversely the opposite mapping of bits: 0->01 and 1->10 is A133468.
The bit length of a(n) is 2^(n-1)+1.
The count of bits set for a(n) is A094373(n).
a(n) = 2 (mod 4) for n > 1.
Also all the terms align bitwise to the right.
The hamming distance of a(n) and a(n+1) is in A000079.

Examples

			For n = 5 a(5) = 406 because:
This encoding results in the following tree:
n | a(n)
--+---------------
1 | 0
  | |\
2 | 1 0
  | | |
3 | 1 10
  | | | \
4 | 1 01 10--
  | | |\  \  \
  | | | \  \  \
5 | 1 10 01 01 10
Which also aligns bitwise to the right:
n | a(n)
--+-----------
1 |         0
2 |        10
3 |       110
4 |     10110
5 | 110010110
And 110010110 in base 10 is 406.
		

Crossrefs

Programs

  • Mathematica
    NestList[FromDigits[2 - IntegerDigits[#, 2], 4] &, 0, 10] (* Paolo Xausa, Nov 04 2024 *)
  • Python
    from functools import cache
    A374625 = lambda n: int(bin(n)[2:].replace('0', '2'), 4)
    @cache
    def a(n):
      if n == 1: return 0
      return A374625(a(n-1))
    print([a(n) for n in range(1, 12)])

Formula

a(n) = A320916(2^(n-2)+1) for n > 1.
A000120(a(n+1) XOR a(n)) = A000079(n-2).
a(n) = A374625(a(n-1)) for n > 1. - Paolo Xausa, Nov 04 2024

A383976 In the binary expansion of n, expand bits 1 -> 11 and 0 -> 10.

Original entry on oeis.org

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

Views

Author

Darío Clavijo, May 16 2025

Keywords

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.

Crossrefs

Programs

  • 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 *)
  • Python
    a = lambda n: int(bin(n)[2:].replace('1','3').replace('0','2'),4)
    print([a(n) for n in range(0,51)])

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.
Showing 1-4 of 4 results.