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-6 of 6 results.

A088161 n rotated one binary place to the right less n rotated one binary place to the left.

Original entry on oeis.org

0, 0, 0, 0, 1, 3, -2, 0, 3, 9, 0, 6, -3, 3, -6, 0, 7, 21, 4, 18, 1, 15, -2, 12, -5, 9, -8, 6, -11, 3, -14, 0, 15, 45, 12, 42, 9, 39, 6, 36, 3, 33, 0, 30, -3, 27, -6, 24, -9, 21, -12, 18, -15, 15, -18, 12, -21, 9, -24, 6, -27, 3, -30, 0, 31, 93, 28, 90, 25, 87, 22, 84, 19, 81, 16, 78, 13, 75, 10, 72, 7, 69, 4
Offset: 0

Views

Author

Robert G. Wilson v, Sep 13 2003

Keywords

Comments

f(n) is negative about 2/7 of the time to 10^7. f(n) is zero, see A088163.

Crossrefs

Programs

  • Maple
    f:= proc(n) local a,b;
      if n::even then a:= n/2 else a:= 2^ilog2(n) + (n-1)/2 fi;
      if n = 0 then b:= 0 else b:= 2*n + 1 - 2^(ilog2(n)+1) fi;
      a-b
    end proc:
    map(f, [$0..200]); # Robert Israel, Mar 03 2025
  • Mathematica
    f[n_] := FromDigits[ RotateRight[ IntegerDigits[n, 2]], 2] - FromDigits[ RotateLeft[ IntegerDigits[n, 2]], 2]; Table[ f[n], {n, 0, 82}]

Formula

a(n) = A038572(n) - A006257(n).

A273105 a(n) = A038572(n) + A006257(n), sum of the two numbers obtained by rotating the binary representation of n by one place to the right and to the left.

Original entry on oeis.org

0, 2, 2, 6, 3, 9, 8, 14, 5, 15, 10, 20, 15, 25, 20, 30, 9, 27, 14, 32, 19, 37, 24, 42, 29, 47, 34, 52, 39, 57, 44, 62, 17, 51, 22, 56, 27, 61, 32, 66, 37, 71, 42, 76, 47, 81, 52, 86, 57, 91, 62, 96, 67, 101, 72, 106, 77, 111, 82, 116, 87, 121, 92, 126, 33, 99
Offset: 0

Views

Author

Alex Ratushnyak, May 15 2016

Keywords

Crossrefs

Programs

  • Mathematica
    Table[FromDigits[RotateRight@ #, 2] + FromDigits[RotateLeft@ #, 2] &@ IntegerDigits[n, 2], {n, 0, 65}] (* Michael De Vlieger, May 17 2016 *)
  • Python
    print('0', end=',')
    for n in range(1,1000):
        BL = len(bin(n))-2
        x = (n>>1) + ((n&1) << (BL-1))   # A038572(n)
        x+= (n*2) - (1<A006257(n)  for n>0
        print(str(x), end=',')

A368427 A permutation related to the Christmas tree pattern map (A367508): a(1) = 1, and for any n > 1, a(n) = A053644(n) + A367562(n-1).

Original entry on oeis.org

1, 2, 3, 6, 4, 5, 7, 12, 13, 10, 14, 8, 9, 11, 15, 26, 24, 25, 27, 28, 20, 21, 29, 18, 22, 30, 16, 17, 19, 23, 31, 52, 53, 50, 54, 48, 49, 51, 55, 56, 57, 42, 58, 40, 41, 43, 59, 44, 60, 36, 37, 45, 61, 34, 38, 46, 62, 32, 33, 35, 39, 47, 63, 106, 104, 105
Offset: 1

Views

Author

Rémy Sigrist, Dec 24 2023

Keywords

Comments

This sequence is a permutation of the positive integers (with inverse A368428):
- the Christmas tree pattern map runs through all finite nonempty binary words,
- by prefixing these words with a 1, we obtain the binary expansions of all integers >= 2,
- hence, with the leading term a(1) = 1, we have a permutation of the positive integers.
Apparently, A088163 \ {0} corresponds to the fixed points.
We can also obtain this sequence by applying the Christmas tree pattern map starting from the chain "1" (instead of "0 1") and converting the resulting binary words to decimal.

Examples

			The first terms, alongside their binary expansion and the corresponding word in the Christmas tree pattern map, are:
  n   a(n)  bin(a(n))  Xmas word
  --  ----  ---------  ---------
   1     1          1        N/A
   2     2         10          0
   3     3         11          1
   4     6        110         10
   5     4        100         00
   6     5        101         01
   7     7        111         11
   8    12       1100        100
   9    13       1101        101
  10    10       1010        010
  11    14       1110        110
  12     8       1000        000
  13     9       1001        001
  14    11       1011        011
  15    15       1111        111
		

Crossrefs

Programs

  • Mathematica
    With[{imax=7},Map[FromDigits[#,2]&,Flatten[NestList[Map[Delete[{If[Length[#]>1,Map[#<>"0"&,Rest[#]],Nothing],Join[{#[[1]]<>"0"},Map[#<>"1"&,#]]},0]&],{{"1"}},imax-1]]]] (* Generates terms up to order 7 *) (* Paolo Xausa, Dec 28 2023 *)
  • PARI
    See Links section.
    
  • Python
    from itertools import islice
    from functools import reduce
    def uniq(r): return reduce(lambda u, e: u if e in u else u+[e], r, [])
    def agen():  # generator of terms
        R = [["1"]]
        while R:
            r = R.pop(0)
            yield from map(lambda b: int(b, 2), r)
            if len(r) > 1: R.append(uniq([r[k]+"0" for k in range(1, len(r))]))
            R.append(uniq([r[0]+"0", r[0]+"1"] + [r[k]+"1" for k in range(1, len(r))]))
    print(list(islice(agen(), 66))) # Michael S. Branicky, Dec 24 2023

A273106 Numbers representable as ror(k)+rol(k), where ror(k)=A038572(k) is k rotated one binary place to the right, rol(k)=A006257(k) is k rotated one binary place to the left.

Original entry on oeis.org

0, 2, 3, 5, 6, 8, 9, 10, 14, 15, 17, 19, 20, 22, 24, 25, 27, 29, 30, 32, 33, 34, 37, 38, 39, 42, 43, 44, 47, 48, 51, 52, 53, 56, 57, 58, 61, 62, 63, 65, 66, 67, 68, 70, 71, 72, 73, 75, 76, 77, 78, 80, 81, 82, 83, 85, 86, 87, 88, 90, 91, 92, 93, 95, 96, 98
Offset: 0

Views

Author

Alex Ratushnyak, May 15 2016

Keywords

Crossrefs

Programs

  • Mathematica
    Take[#, 66] &@ Union@ Table[FromDigits[RotateRight@ #, 2] + FromDigits[RotateLeft@ #, 2] &@ IntegerDigits[n, 2], {n, 0, 10^3}] (* Michael De Vlieger, May 17 2016 *)
  • Python
    def ROR(n):                # returns A038572(n)
        BL = len(bin(n))-2
        return (n>>1) + ((n&1) << (BL-1))
    def ROL(n):                # returns A006257(n) for n>0
        BL = len(bin(n))-2
        return (n*2) - (1<
    				

A273180 Numbers n such that ror(n) + rol(n) is a power of 2, where ror(n)=A038572(n) is n rotated one binary place to the right, rol(n)=A006257(n) is n rotated one binary place to the left.

Original entry on oeis.org

1, 2, 6, 19, 38, 102, 307, 614, 1638, 4915, 9830, 26214, 78643, 157286, 419430, 1258291, 2516582, 6710886, 20132659, 40265318, 107374182, 322122547, 644245094, 1717986918, 5153960755, 10307921510, 27487790694, 82463372083, 164926744166, 439804651110
Offset: 1

Views

Author

Alex Ratushnyak, May 17 2016

Keywords

Crossrefs

Programs

  • C
    #include 
    int main(int argc, char** argv)
    {
      unsigned long long x, n, BL=0;
      for (n=1; n>0; ++n) {
        if ((n & (n-1))==0)  ++BL;
        x = (n>>1) + ((n&1) << (BL-1));   // A038572(n)
        x+= (n*2) - (1ull<A006257(n)  for n>0
        if ((x & (x-1))==0)  printf("%lld, ", n);
      }
    }
    
  • Mathematica
    Select[Range[10^6], IntegerQ@ Log2[FromDigits[RotateRight@ #, 2] + FromDigits[RotateLeft@ #, 2]] &@ IntegerDigits[#, 2] &] (* or *)
    Rest@ CoefficientList[Series[x (1 + 2 x + 6 x^2 + 2 x^3 + 4 x^4)/((1 - x) (1 + x + x^2) (1 - 16 x^3)), {x, 0, 30}], x] (* Michael De Vlieger, May 19 2016 *)
  • PARI
    Vec(x*(1+2*x+6*x^2+2*x^3+4*x^4)/((1-x)*(1+x+x^2)*(1-16*x^3)) + O(x^50)) \\ Colin Barker, May 19 2016

Formula

From Colin Barker, May 19 2016: (Start)
a(n) = 17*a(n-3) - 16*a(n-6) for n>6.
G.f.: x*(1+2*x+6*x^2+2*x^3+4*x^4) / ((1-x)*(1+x+x^2)*(1-16*x^3)).
(End)

A273050 Numbers k such that ror(k) XOR rol(k) = k, where ror(x)=A038572(x) is x rotated one binary place to the right, rol(x)=A006257(x) is x rotated one binary place to the left, and XOR is the binary exclusive-or operator.

Original entry on oeis.org

0, 5, 6, 45, 54, 365, 438, 2925, 3510, 23405, 28086, 187245, 224694, 1497965, 1797558, 11983725, 14380470, 95869805, 115043766, 766958445, 920350134, 6135667565, 7362801078, 49085340525, 58902408630, 392682724205, 471219269046
Offset: 1

Views

Author

Alex Ratushnyak, May 13 2016

Keywords

Crossrefs

Cf. A006257, A038572, A088163, A125836 (bisection?), A125837 (bisection?).
Cf. A020988 (numbers k such that ror(k) + rol(k) = k).

Programs

  • Mathematica
    ok[n_] := Block[{x = IntegerDigits[n, 2]}, x == BitXor @@@ Transpose@ {RotateLeft@ x, RotateRight@ x}]; Select[ Range[0, 10^5], ok] (* Giovanni Resta, May 14 2016 *)
    ok[n_] := Block[{x = IntegerDigits[n, 2]}, x == BitXor @@@ Transpose[ {RotateLeft[x], RotateRight[x]}]]; Select[LinearRecurrence[{0, 9, 0, -8}, {0, 5, 6, 45}, 100], ok] (* Jean-François Alcover, May 22 2016, after Giovanni Resta *)
  • Python
    def ROR(n):                # returns A038572(n)
        BL = len(bin(n))-2
        return (n>>1) + ((n&1) << (BL-1))
    def ROL(n):                # returns A006257(n) for n>0
        BL = len(bin(n))-2
        return (n*2) - (1<
    				

Formula

Conjectures from Colin Barker, May 22 2016: (Start)
a(n) = (-11+(-1)^n+2^(-1/2+(3*n)/2)*(3-3*(-1)^n+5*sqrt(2)+5*(-1)^n*sqrt(2)))/14.
a(n) = 5*(2^(3*n/2)-1)/7 for n even.
a(n) = 3*(2^((3*n)/2-1/2)-2)/7 for n odd.
a(n) = 9*a(n-2)-8*a(n-4) for n>4.
G.f.: x^2*(5+6*x) / ((1-x)*(1+x)*(1-8*x^2)).
(End)

Extensions

a(19)-a(27) from Giovanni Resta, May 14 2016
Showing 1-6 of 6 results.