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

A065609 Positive m such that when written in binary, no rotated value of m is greater than m.

Original entry on oeis.org

1, 2, 3, 4, 6, 7, 8, 10, 12, 14, 15, 16, 20, 24, 26, 28, 30, 31, 32, 36, 40, 42, 48, 50, 52, 54, 56, 58, 60, 62, 63, 64, 72, 80, 84, 96, 98, 100, 104, 106, 108, 112, 114, 116, 118, 120, 122, 124, 126, 127, 128, 136, 144, 160, 164, 168, 170, 192, 194, 196, 200, 202
Offset: 1

Views

Author

Jonathan Ayres (jonathan.ayres(AT)btinternet.com), Nov 06 2001

Keywords

Comments

Rotated values of m are defined as the numbers which occur when m is shifted 1, 2, ... bits to the right with the last bits added to the front; e.g., the rotated values of 1011 are 1011, 1101, 1110 and 0111.
The number of k-bit binary numbers in this sequence is A008965. This gives the row lengths when the sequence is regarded as a table.
If m is in the sequence, then so is 2m. All odd terms are of the form 2^k - 1. - Ivan Neretin, Aug 04 2016
First differs from A328595 in lacking 44, with binary expansion {1, 0, 1, 1, 0, 0}, and 92, with binary expansion {1, 0, 1, 1, 1, 0, 0}. - Gus Wiseman, Oct 31 2019

Examples

			14 is included because 14 in binary is 1110. 1110 has the rotated values of 0111, 1011 and 1101 -- 7, 11 and 13 -- which are all smaller than 14.
		

Crossrefs

A similar concept is A328595.
The version with the most significant digit ignored is A328668 or A328607.
Numbers whose reversed binary expansion is a Lyndon word are A328596.
Numbers whose binary expansion is aperiodic are A328594.
Binary necklaces are A000031.
Necklace compositions are A008965.

Programs

  • Maple
    filter:= proc(n) local L, k;
      if n::odd then return evalb(n+1 = 2^ilog2(n+1)) fi;
      L:= convert(convert(n,binary),string);
      for k from 1 to length(L)-1 do
        if not lexorder(StringTools:-Rotate(L,k),L) then return false fi;
      od;
      true
    end proc:
    select(filter, [$1..1000]); # Robert Israel, Aug 05 2016
  • Mathematica
    Select[Range[200], # == Max[FromDigits[#, 2] & /@ NestList[RotateLeft, dg = IntegerDigits[#, 2], Length@dg]] &] (* Ivan Neretin, Aug 04 2016 *)
  • Python
    def ok(n):
        b = bin(n)[2:]
        return b > "0" and all(b[i:] + b[:i] <= b for i in range(1, len(b)))
    print([k for k in range(203) if ok(k)]) # Michael S. Branicky, May 26 2022

Extensions

Edited by Franklin T. Adams-Watters, Apr 09 2010

A163382 a(n) = the (decimal equivalent of the) smallest integer that can be made by rotating the binary digits of n any number of positions to the left or right, where a(n) in binary must contain the same number of digits (without any leading 0's) as n written in binary.

Original entry on oeis.org

1, 2, 3, 4, 5, 5, 7, 8, 9, 10, 11, 9, 11, 11, 15, 16, 17, 18, 19, 18, 21, 21, 23, 17, 19, 21, 23, 19, 23, 23, 31, 32, 33, 34, 35, 36, 37, 38, 39, 34, 38, 42, 43, 37, 45, 43, 47, 33, 35, 37, 39, 38, 43, 45, 47, 35, 39, 43, 47, 39, 47, 47, 63, 64, 65, 66, 67, 68, 69, 70, 71, 68, 73
Offset: 1

Views

Author

Leroy Quet, Jul 25 2009

Keywords

Comments

By rotating the binary digits of n, it is meant: Write n in binary without any leading 0's. To rotate this string to the right, say, by one position, first remove the rightmost digit and then append it on the left side of the remaining string. (So the least significant digit becomes the most significant digit.) Here, leading 0's are not removed after the first rotation, so that each binary string being rotated has the same number of binary digits as n.
Alternatively, compute n in binary and denote the number of digits by d. Concatenate the binary number to itself. In the new "number", find the smallest binary number with length d and a leading 1. - David A. Corneth, Sep 28 2017

Examples

			13 in binary is 1101. Rotating this just once to the right, we get 1110, 14 in decimal. If we rotate twice to the right, we would have had 0111 = 7 in decimal. Rotating 3 times, we end up with 1011, which is 11 in decimal. Rotating 4 times, we end up at the beginning with 1101 = 13. 7 is the smallest of these, but it contains a 0 in the leftmost position of its 4-digit binary representation. 11 (decimal), on the other hand, is the smallest with a 1 in the leftmost position of its 4-digit binary representation. So a(13) = 11.
20 in binary is 10100 and has 5 digits. Concatenating the binary expansion of 20 to itself gives 1010010100. The shortest binary number of length 5 is 10010, which corresponds to 18 in decimal. Therefore, a(20) = 18. - _David A. Corneth_, Sep 28 2017
		

Crossrefs

Programs

  • Maple
    a:= proc(n) local i, k, m, s;
          k, m, s:= ilog2(n), n, n;
          for i to k do m:= iquo(m, 2, 'd') +d*2^k;
              if d=1 then s:=s, m fi od;
          min(s)
        end:
    seq(a(n), n=1..80);  # Alois P. Heinz, May 24 2012
  • Mathematica
    Table[With[{d = IntegerDigits[n, 2]}, Min@ Map[FromDigits[#, 2] &, Select[Map[RotateRight[d, #] &, Range[Length@ d]], First@ # == 1 &]]], {n, 73}] (* Michael De Vlieger, Sep 23 2017 *)
  • PARI
    a(n) = {my(b = binary(n), l = List(), m = #b, v, r = 2^m); b = concat(b, b); for(i=1, m, if(b[i]==1, r = min(r, fromdigits(vector(m, j, b[i + j - 1]), 2)))); r} \\ David A. Corneth, Sep 28 2017

Extensions

Corrected and extended by Sean A. Irvine, Nov 08 2009

A163380 a(n) = the (decimal equivalent of the) largest integer that can be made by rotating the binary digits of n any number of positions to the left or right.

Original entry on oeis.org

1, 2, 3, 4, 6, 6, 7, 8, 12, 10, 14, 12, 14, 14, 15, 16, 24, 20, 28, 20, 26, 26, 30, 24, 28, 26, 30, 28, 30, 30, 31, 32, 48, 40, 56, 36, 50, 52, 60, 40, 52, 42, 58, 50, 54, 58, 62, 48, 56, 50, 60, 52, 58, 54, 62, 56, 60, 58, 62, 60, 62, 62, 63, 64, 96, 80, 112, 72, 98, 104, 120
Offset: 1

Views

Author

Leroy Quet, Jul 25 2009

Keywords

Comments

By rotating the binary digits of n, it is meant: Write n in binary without any leading 0's. To rotate this string to the right, say, by one position, first remove the rightmost digit and then append it on the left side of the remaining string. (So the least significant digit becomes the most significant digit.) Here, leading 0's are not removed after the first rotation, so that each binary string being rotated has the same number of binary digits as n has.

Examples

			13 in binary is 1101. Rotating this just once to the right, we get 1110, 14 in decimal. If we rotate twice to the right, we would have had 0111 = 7 in decimal. Rotating 3 times, we end up with 1011, which is 11 in decimal. Rotating 4 times, we end up at the beginning with 1101 = 13. 14 is the largest of these, so a(13) = 14.
		

Crossrefs

Programs

  • Maple
    rot := proc(n,t) convert(n,base,2) ; bdgs := ListTools[Rotate](%,t) ; add(op(i,bdgs)*2^(i-1),i=1..nops(bdgs)) ; end: A163380 := proc(n) local a,r; a := n ; for r from 1 to ilog2(n) do a := max(a, rot(n,r)) ; od: a; end: seq(A163380(n),n=1..100) ; # R. J. Mathar, Aug 03 2009
  • Mathematica
    Table[With[{d = IntegerDigits[n, 2]}, Max@ Map[FromDigits[#, 2] &@ RotateRight[d, #] &, Range[Length@ d]]], {n, 71}] (* Michael De Vlieger, Sep 23 2017 *)

Extensions

More terms from R. J. Mathar, Aug 03 2009

A347688 Let c (resp. C) be the smallest (resp. largest) number that can be obtained by cyclically permuting the digits of n; a(n) = C - c.

Original entry on oeis.org

0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 0, 9, 18, 27, 36, 45, 54, 63, 72, 18, 9, 0, 9, 18, 27, 36, 45, 54, 63, 27, 18, 9, 0, 9, 18, 27, 36, 45, 54, 36, 27, 18, 9, 0, 9, 18, 27, 36, 45, 45, 36, 27, 18, 9, 0, 9, 18, 27, 36, 54, 45, 36, 27, 18, 9, 0, 9, 18, 27, 63, 54, 45, 36, 27, 18, 9, 0, 9, 18, 72, 63, 54, 45, 36, 27, 18, 9, 0, 9, 81, 72, 63, 54, 45, 36, 27, 18, 9, 0, 99, 99, 189, 279, 369, 459, 549, 639, 729, 819, 99, 0, 99
Offset: 0

Views

Author

N. J. A. Sloane, Sep 22 2021, following a suggestion from Joseph Rozhenko

Keywords

Comments

Agrees with A151949 for n <= 101.
All terms are multiples of 9 (cf. A347689).
Repeatedly applying the operation of subtracting the smallest cyclic permutation from the largest produces interesting sequences. It appears that n-digit numbers converge to a small number m << n of loops. Any 3-digit number converges to one of two loops of length 3: (189, 729, 675) and (378, 459, 486); any 4-digit number to either of (189, 729, 675) or a loop of length 25; any 5-digit number to one of three loops of length 3: (38007, 79335, 59778), (48780, 82926, 65853), or (29889, 69003, 89667), and so on. For 6-digit numbers there are 10 loops (of lengths 1, 2, 3, 10, 12 or 60). - Joseph Rozhenko, Oct 05 2021
For any cyclic number N, there must exist a cyclic permutation P of N for which a(P) = P. - Joseph Rozhenko, Oct 07 2021
An interesting plot of this sequence comes up when the axes are not n vs. a(n), but rather C vs. c. In other words, each number a(n) is represented on the X axis by C (largest number that can be obtained by cyclically permuting the digits of n) and on the Y axis as c (smallest number that can be obtained by cyclically permuting the digits of n). - Joseph Rozhenko, Jan 26 2022

Examples

			If n = 102, c = 21, C = 210, a(102) = 210 - 21 = 189.
		

Crossrefs

Programs

  • Maple
    A347688 := proc(n)
            local dgs,C,c,ndgs,r ;
            dgs := convert(n,base,10) ;
            ndgs := nops(dgs) ;
            C := digcatL(dgs) ;
            c := C ;
            for r from 0 to ndgs-1 do
                    C := max(C,digcatL(dgs)) ;
                    c := min(c,digcatL(dgs)) ;
                    dgs := ListTools[Rotate](dgs,1) ;
            end do:
            C-c ;
    end proc: # R. J. Mathar, Sep 27 2021
  • Mathematica
    {0}~Join~Table[First@Differences@MinMax[FromDigits/@(RotateLeft[IntegerDigits@n,#]&/@Range@IntegerLength@n)],{n,112}] (* Giorgos Kalogeropoulos, Sep 22 2021 *)
  • PARI
    a(n, base=10) = { my (c=n, C=n, d=digits(n, base)); for (k=1, #d, my (r=fromdigits(concat(d[k+1..#d], d[1..k]), base)); c=min(c, r); C=max(C, r)); C-c } \\ Rémy Sigrist, Sep 22 2021
    
  • Python
    def a(n):
        s = str(n)
        cyclic_perms = [int("".join(s[i:] + s[:i])) for i in range(len(s))]
        c, C = min(cyclic_perms), max(cyclic_perms)
        return C - c
    print([a(n) for n in range(113)]) # Michael S. Branicky, Sep 26 2021

Formula

a(n) = 0 iff n belongs to A010785. - Rémy Sigrist, Sep 22 2021

Extensions

More than the usual number of terms are shown in order to distinguish this from similar sequences.

A212713 The (decimal equivalent of the) smallest integer that can be made by rotating the base three digits of n any number of positions to the left or right.

Original entry on oeis.org

1, 2, 1, 4, 5, 2, 5, 8, 1, 4, 7, 4, 13, 14, 5, 14, 17, 2, 5, 8, 7, 14, 17, 8, 17, 26, 1, 4, 7, 10, 13, 16, 11, 22, 25, 4, 13, 22, 13, 40, 41, 14, 41, 44, 5, 14, 23, 16, 41, 50, 17, 44, 53, 2, 5, 8, 11, 14, 17, 20, 23, 26, 7, 16, 25, 22, 41, 44, 23, 50, 53, 8
Offset: 1

Views

Author

John W. Layman, May 24 2012

Keywords

Comments

The corresponding sequence using binary representations is given in A163381.

Examples

			For n=10, the rotations are 101(base 3)=10, 011=4, and 110=12, so a(10)=4.
		

Crossrefs

Cf. A163381.

Programs

  • Maple
    a:= proc(n) local i, k, m, s;
          k, m, s:= ilog[3](n), n, n;
          for i to k do m:= iquo(m, 3, 'd') +d*3^k; s:=s, m od;
          min(s)
        end:
    seq(a(n), n=1..80);  # Alois P. Heinz, May 24 2012
  • Mathematica
    a = {}; For[n = 1, n <= 100, n++, {m = n; d = IntegerDigits[n, 3];
      For[k = 1, k <= Length[d], k++, {d = RotateLeft[d]; v = FromDigits[d, 3]; If[v < m, m = v]; }]; AppendTo[a, m]}]; a
    smr3[n_]:=With[{id3=IntegerDigits[n,3]},Min[FromDigits[#,3]&/@Table[RotateRight[id3,k],{k,Length[id3]}]]]; Array[smr3,80] (* Harvey P. Dale, Jan 29 2025 *)
Showing 1-5 of 5 results.