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.

Previous Showing 21-30 of 31 results. Next

A255593 Convert n to base 8, move least significant digit to most significant digit and convert back to base 10.

Original entry on oeis.org

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

Views

Author

Paolo P. Lava, Mar 02 2015

Keywords

Comments

a(8*n) = n.
a(8^n) = 8^(n-1).
Fixed points of the transform are listed in A048333.

Examples

			13 in base 8 is 15: moving the least significant digit as the most significant one we have 51 that is 41 in base 10.
		

Crossrefs

Programs

  • Maple
    with(numtheory): P:=proc(q,h) local a,b,k,n; print(0);
    for n from 1 to q do
    a:=convert(n,base,h); b:=[]; for k from 2 to nops(a) do b:=[op(b),a[k]]; od; a:=[op(b),a[1]];
    a:=convert(a,base,h,10); b:=0; for k from nops(a) by -1 to 1 do b:=10*b+a[k]; od;
    print(b); od; end: P(10^4,8);
  • Mathematica
    roll[n_, b_] := Block[{w = IntegerDigits[n, b]}, Prepend[Most@ w, Last@ w]]; b = 8; FromDigits[#, b] & /@ (roll[#, b] & /@ Range[0, 69]) (* Michael De Vlieger, Mar 04 2015 *)
    Table[FromDigits[RotateRight[IntegerDigits[n,8]],8],{n,0,70}] (* Harvey P. Dale, Apr 28 2017 *)

A336953 In binary representation, rotate the digits of n right n places.

Original entry on oeis.org

0, 1, 2, 3, 2, 3, 6, 7, 8, 12, 10, 7, 12, 14, 11, 15, 8, 12, 10, 7, 20, 26, 21, 30, 17, 25, 13, 30, 19, 27, 30, 31, 8, 12, 10, 7, 36, 50, 41, 60, 34, 19, 42, 53, 11, 45, 58, 31, 48, 56, 44, 30, 19, 43, 54, 59, 14, 15, 43, 55, 60, 62, 47, 63, 32, 48, 40, 28
Offset: 0

Views

Author

Gage Schacher, Aug 08 2020

Keywords

Comments

On the graph, there are a series of larger and larger parallelograms joined together by a straight line on y=x where n is unchanged, mostly in the case where n is a multiple of the bit length of n. In addition to the main line that cuts through the graph, each parallelogram has the same few sloped lines in its borders.

Examples

			a(3) = a('11') = '11' = 3;
a(4) = a('100') = '010' = '10' = 2;
a(5) = a('101') = '011' = '11' = 3;
		

Crossrefs

Cf. A007088, A038572 (rotated one binary place to the right).
Cf. A366139 (rotate left), A366140 (fixed points).

Programs

  • Mathematica
    Array[FromDigits[RotateRight[IntegerDigits[#, 2], #], 2] &, 68, 0] (* Michael De Vlieger, Oct 05 2020 *)
  • PARI
    a(n) = my(d=binary(n)); for (k=1, n, d = concat(d[#d], d[1..#d-1])); fromdigits(d, 2); \\ Michel Marcus, Aug 09 2020
    
  • Python
    def A336953(n):
        if n == 0: return 0
        l, m = -(n%n.bit_length()), bin(n)[2:]
        return int(m[l:]+m[:l],2) # Chai Wah Wu, Jan 22 2023

A383849 In the binary representation of n, rotate right by the number of ones.

Original entry on oeis.org

0, 1, 1, 3, 2, 3, 5, 7, 4, 6, 10, 7, 3, 11, 13, 15, 8, 12, 20, 14, 5, 22, 26, 15, 6, 7, 11, 23, 19, 27, 29, 31, 16, 24, 40, 28, 9, 44, 52, 30, 10, 13, 21, 46, 37, 54, 58, 31, 12, 14, 22, 15, 38, 23, 27, 47, 7, 39, 43, 55, 51, 59, 61, 63, 32, 48, 80, 56, 17, 88, 104, 60, 18
Offset: 0

Views

Author

Paolo Xausa, May 13 2025

Keywords

Comments

Equivalently, rotate left by the number of zeros.

Examples

			a(19) = 14 because 19 = 10011_2, and 10011_2 rotated to the right 3 times gives 01110_2 = 14.
		

Crossrefs

Cf. A007088, A038572, A383848, A383850 (fixed points).

Programs

  • Mathematica
    A383849[n_] := FromDigits[RotateRight[#, Total[#]], 2] & [IntegerDigits[n, 2]];
    Array[A383849, 100, 0]

A053641 Rotate n one binary digit to the right, drop leading zeros, then rotate one binary digit to the left.

Original entry on oeis.org

1, 1, 3, 1, 5, 3, 7, 1, 9, 3, 11, 5, 13, 7, 15, 1, 17, 3, 19, 5, 21, 7, 23, 9, 25, 11, 27, 13, 29, 15, 31, 1, 33, 3, 35, 5, 37, 7, 39, 9, 41, 11, 43, 13, 45, 15, 47, 17, 49, 19, 51, 21, 53, 23, 55, 25, 57, 27, 59, 29, 61, 31, 63, 1
Offset: 1

Views

Author

Henry Bottomley, Mar 22 2000

Keywords

Examples

			a(60) = 29 because starting with 111100 the right rotation produces 011110,  written as 11110 (i.e., 30) and the left rotation produces 11101 (i.e., 29).
		

Crossrefs

Cf. A053642 (left then right).

Programs

  • Mathematica
    rtt[f_, n_] := FromDigits[f[IntegerDigits[n, 2]], 2];
    Array[rtt[RotateLeft, rtt[RotateRight, #]]&, 100] (* Paolo Xausa, Jan 16 2024 *)
  • PARI
    a(n) = if(bitand(n,1), n, n+1 - 1<Kevin Ryde, Jan 13 2024

Formula

a(n) = A006257(A038572(n)).
a(n) = n if n odd, n - 2^k + 1 if n even and 2^k <= n < 2^(k+1).

A053642 Rotate n one binary digit to the left, drop leading zeros, then rotate one binary digit to the right.

Original entry on oeis.org

1, 1, 3, 1, 3, 6, 7, 1, 3, 6, 7, 12, 13, 14, 15, 1, 3, 6, 7, 12, 13, 14, 15, 24, 25, 26, 27, 28, 29, 30, 31, 1, 3, 6, 7, 12, 13, 14, 15, 24, 25, 26, 27, 28, 29, 30, 31, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 1
Offset: 1

Views

Author

Henry Bottomley, Mar 22 2000

Keywords

Comments

Sequence contains ever-longer copies of A004760. - Ralf Stephan, Sep 16 2003

Examples

			a(22)=14 because starting with 10110 the left rotation produces 01101 written as 1101 (i.e., 13) and the right rotation produces 1110 (i.e., 14).
		

Crossrefs

Cf. A053641 (right then left).

Programs

  • Mathematica
    rtt[f_, n_] := FromDigits[f[IntegerDigits[n, 2]], 2];
    Array[rtt[RotateRight, rtt[RotateLeft, #]]&, 100] (* Paolo Xausa, Jan 16 2024 *)
  • PARI
    a(n) = n-=1<Kevin Ryde, Jan 13 2024

Formula

a(n) = A038572(A006257(n)).
a(n) = n if 3*2^(k-1) <= n < 2^(k+1);
a(n) = a(n - 2^(k-1)) if 2^k <= n < 3*2^(k-1).
a(2n) = 2a(n) - [a(n)==1], a(2n+1) = 2a(n) + 1. - Ralf Stephan, Sep 16 2003

A336962 Right-rotate run-lengths of consecutive equal digits in binary representation of n.

Original entry on oeis.org

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

Views

Author

Rémy Sigrist, Aug 09 2020

Keywords

Comments

This sequence is a permutation of the nonnegative integers, with inverse A336963.

Examples

			The first terms, in decimal and in binary, are:
  n   a(n)  bin(n)  bin(a(n))
  --  ----  ------  ---------
   0     0       0          0
   1     1       1          1
   2     2      10         10
   3     3      11         11
   4     6     100        110
   5     5     101        101
   6     4     110        100
   7     7     111        111
   8    14    1000       1110
   9    11    1001       1011
  10    10    1010       1010
  11    13    1011       1101
  12    12    1100       1100
  13     9    1101       1001
  14     8    1110       1000
  15    15    1111       1111
		

Crossrefs

Programs

  • PARI
    toruns(n) = { my (r=[]); while (n, my (v=valuation(n+n%2,2)); n\=2^v; r=concat(v,r)); r }
    fromruns(r) = { my (v=0); for (k=1, #r, v=(v+k%2)*2^r[k]-k%2); v }
    a(n) = { my (r=toruns(n)); fromruns(vector(#r, k, r[1+(k-2)%#r])) }

Formula

a(n) = n iff n = 0 or n belongs to A140690.

A063251 Least number of binary rotations needed to reach fixed point (with either left or right rotation allowed at each iteration).

Original entry on oeis.org

0, 0, 1, 0, 1, 1, 1, 0, 1, 1, 2, 1, 2, 2, 1, 0, 1, 1, 2, 1, 2, 2, 2, 1, 2, 2, 3, 2, 2, 2, 1, 0, 1, 1, 2, 1, 2, 2, 2, 1, 2, 2, 3, 2, 3, 3, 2, 1, 2, 2, 3, 2, 3, 3, 3, 2, 3, 3, 3, 3, 2, 2, 1, 0, 1, 1, 2, 1, 2, 2, 2, 1, 2, 2, 3, 2, 3, 3, 2, 1, 2, 2, 3, 2, 3, 3, 3, 2, 3, 3, 4, 3, 3, 4, 2, 1, 2, 2, 3, 2, 3, 3, 3, 2, 3
Offset: 0

Views

Author

Marc LeBrun, Jul 11 2001

Keywords

Comments

Fixed points are of the form 2^k-1. Left rotation is A006257, right rotation is A038572. Only-left order is A048881, only-right order is A063250. n for which mixed L/R order beats min of only-left, only-right is A063252.

Examples

			a(22)=2 with 22 right-> 11 left-> 7. (only-left requires 3, only-right requires 4)
		

Crossrefs

A243589 Numbers returned when each binary digit of n is replaced by the sum modulo 2 of the digits to its (wrapped) left and (wrapped) right.

Original entry on oeis.org

0, 0, 0, 3, 5, 6, 0, 5, 15, 0, 10, 15, 5, 10, 0, 9, 27, 12, 30, 3, 17, 6, 20, 29, 15, 24, 10, 23, 5, 18, 0, 17, 51, 20, 54, 27, 57, 30, 60, 5, 39, 0, 34, 15, 45, 10, 40, 57, 27, 60, 30, 51, 17, 54, 20, 45, 15, 40, 10, 39, 5, 34, 0, 33, 99, 36, 102, 43, 105, 46
Offset: 1

Views

Author

Anthony Sand, Jun 07 2014

Keywords

Comments

a(n) = ror(n) XOR rol(n), 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. - Alex Ratushnyak, May 24 2016
Numbers returned by the following function: take the t binary digits of n, d(1)..d(t), and replace each with the sum d(i) = (d(i-1) + d(i+1)) mod 2, where (i-1 = 0) maps to t and (i+1 > t) maps to 1.

Examples

			For 1, the function returns d(1) = (d(1) + d(1)) mod 2 = (1 + 1) mod 2 = 0.
For 5, the initial digits are (1,0,1).
d(1) = (d(3) + d(2)) mod 2 = (1 + 0) mod 2 = 1; d(2) = (d(1) + d(3)) mod 2 = (1 + 1) mod 2 = 0; d(3) = (d(2) + d(1)) mod 2 = (0 + 1) mod 2 = 1.
The function returns (1,0,1) = 101 = 5 in base 10.
		

Crossrefs

Programs

  • Python
    for n in range(1, 100):
        BL = len(bin(n))-2
        x = (n>>1) + ((n&1) << (BL-1))   # A038572(n)
        x^= (n*2) - (1<A006257(n)  for n>0
        print(x, end=', ')

Formula

for digits d(1)..d(t), d(i) = (d(i-1) + d(i+1)) mod 2, where (i-1 = 0) -> t, (i+1 > t) -> 1.

A281553 Write n in binary reflected Gray code, rotate one binary place to the right and convert the code back to decimal.

Original entry on oeis.org

0, 1, 3, 1, 3, 7, 6, 2, 6, 14, 15, 7, 5, 13, 12, 4, 12, 28, 29, 13, 15, 31, 30, 14, 10, 26, 27, 11, 9, 25, 24, 8, 24, 56, 57, 25, 27, 59, 58, 26, 30, 62, 63, 31, 29, 61, 60, 28, 20, 52, 53, 21, 23, 55, 54, 22, 18, 50, 51, 19, 17, 49, 48, 16, 48, 112, 113, 49, 51, 115, 114, 50, 54, 118
Offset: 0

Views

Author

Indranil Ghosh, Jan 24 2017

Keywords

Comments

a(n) = A003188(n), iff the Elias delta code for n contains all 1's without any zeros (see the example section).

Examples

			For n = 5, the binary reflected Gray code for n is '111'. Rotating one binary place to the right , '111' gives back '111' again. 111_2 = 7_10. So, a(5) = 7. (For n = 5, A003188(n) = 7).
For n = 15, the binary reflected Gray code for n is '1000'. Rotating one binary place to the right, '1000' gives '0100'. 100_2 = 4_10. So, a(15) = 4.
		

Crossrefs

Programs

  • Python
    def rotation(n):
        x=bin(n^(n/2))[2:]
        return int(x[-1]+x[:-1],2)

A374664 Nonnegative numbers whose binary expansion has no ones in common with some of its cyclic shifts.

Original entry on oeis.org

0, 2, 4, 8, 9, 10, 12, 16, 17, 18, 20, 24, 32, 33, 34, 35, 36, 40, 42, 48, 49, 56, 64, 65, 66, 67, 68, 72, 73, 74, 76, 80, 82, 84, 96, 97, 100, 112, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 140, 144, 145, 146, 148, 150, 152, 153, 160, 161, 162
Offset: 1

Views

Author

Rémy Sigrist, Jul 15 2024

Keywords

Comments

Leading zeros in binary expansions are ignored.
All positive terms belong to A072602.
A number k belongs to the sequence iff A001196(k) belongs to the sequence.

Examples

			The first terms, with their binary expansion and an appropriate cyclic shift, are:
  n   a(n)  bin(a(n))  cyc
  --  ----  ---------  ------
   1     0          0       0
   2     2         10      01
   3     4        100     001
   4     8       1000    0001
   5     9       1001    0110
   6    10       1010    0101
   7    12       1100    0011
   8    16      10000   00001
   9    17      10001   00110
  10    18      10010   00101
  11    20      10100   01001
  12    24      11000   00011
  13    32     100000  000001
  14    33     100001  000110
  15    34     100010  000101
  16    35     100011  011100
		

Crossrefs

Programs

  • PARI
    is(n) = { my (x = max(exponent(n), 0), s = n); for (i = 0, x, s = (s >> 1) + if (s%2, 2^x, 0); if (bitand(s, n)==0, return (1););); return (0); }
Previous Showing 21-30 of 31 results. Next