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.

A256999 a(n)=n for n <= 1; for n >= 2, a(n) = largest number that can be obtained by rotating non-msb bits of binary expansion of n (with A080541 or A080542).

Original entry on oeis.org

0, 1, 2, 3, 4, 6, 6, 7, 8, 12, 12, 14, 12, 14, 14, 15, 16, 24, 24, 28, 24, 26, 28, 30, 24, 28, 26, 30, 28, 30, 30, 31, 32, 48, 48, 56, 48, 52, 56, 60, 48, 52, 52, 58, 56, 58, 60, 62, 48, 56, 52, 60, 52, 58, 58, 62, 56, 60, 58, 62, 60, 62, 62, 63, 64, 96, 96, 112, 96, 104, 112, 120, 96, 100, 104, 114, 112, 116, 120, 124, 96, 104, 100
Offset: 0

Views

Author

Antti Karttunen, May 16 2015

Keywords

Crossrefs

Cf. A257250 (fixed points of this sequence).
Cf. also A163380 (analogous sequence when rotating all bits of binary representation).

A163381 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. a(n) in binary may contain fewer digits, after leading 0's are removed, than n written in binary has.

Original entry on oeis.org

1, 1, 3, 1, 3, 3, 7, 1, 3, 5, 7, 3, 7, 7, 15, 1, 3, 5, 7, 5, 11, 11, 15, 3, 7, 11, 15, 7, 15, 15, 31, 1, 3, 5, 7, 9, 11, 13, 15, 5, 13, 21, 23, 11, 27, 23, 31, 3, 7, 11, 15, 13, 23, 27, 31, 7, 15, 23, 31, 15, 31, 31, 63, 1, 3, 5, 7, 9, 11, 13, 15, 9, 19, 21, 23, 19, 27, 29, 31, 5, 13, 21, 29
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. 7 is the smallest of these, so a(13) = 7.
		

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; s:=s, m od;
          min(s)
        end:
    seq(a(n), n=1..80);  # Alois P. Heinz, May 24 2012
  • Mathematica
    Table[Min[FromDigits[ #,2]&/@ NestList[RotateLeft,IntegerDigits[n,2], Floor[Log[2,n]]]],{n,255}] (* Wouter Meeussen, Jul 27 2009 *)
  • PARI
    a(n)=local(k=#binary(n),m=2^k,t=n*(m+1));vecmin(vector(k,x,(t\2^x)%m)) \\ Hagen von Eitzen, Jul 27 2009

Extensions

More terms from Hagen von Eitzen and Wouter Meeussen, Jul 27 2009

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

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