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-10 of 67 results. Next

A348352 Primes p where p-1 is in A328596 (reversed binary expansion is an aperiodic necklace) and the same count of numbers smaller than p-1 are found in A328596 as primes smaller than p exist.

Original entry on oeis.org

2, 3, 5, 7, 13, 233, 433, 27361, 121553, 30536929
Offset: 1

Views

Author

Thomas Scheuerle, Oct 14 2021

Keywords

Comments

If this sequence is infinite, then the density of aperiodic necklaces (Lyndon words) in the reversed binary expansion of numbers and the density of prime numbers, may have some interesting connection. If there exists a deeper relation, an analogy of Goldbach's conjecture based on numbers in A328596 could be investigated, would that provide any new knowledge regarding prime numbers?

Crossrefs

Programs

  • MATLAB
    function a = A348352(max_range)
        a = [];
        bits = floor(log2(max_range))+2;
        p = primes(max_range);
        lw = lyndonwords(1);
        lyndonw = lw{2};
        for n = 2:bits
            lyndonw =[lyndonw lyndonwords(n)];
        end
        for n = 1:length(p)
            prime = p(n);
            wraw = bitget(prime-1,1:bits);
            word = wraw(1:find(wraw == 1, 1, 'last' ));
            if length(lyndonw{n}) == length(word)
                if lyndonw{n} == word
                    a = [a prime];
                end
            end
        end
    end
    function words = lyndonwords(maxlen)
        words = cell(1);
        wordindex = 1;
        w = 0;
        while ~isempty(w)
           len = length(w);
           if(len == maxlen)
                s = [];
                for j = 1:length(w)
                    s = [s w(j)];
                end
                words{wordindex} = s;
                wordindex = wordindex + 1;
            else
                while length(w) < maxlen
                     w = [w w(1+length(w)-len)];
                end
           end
            while ~isempty(w) && w(end) == 1
                w = w(1:end-1);
            end
            if ~isempty(w)
                w(end) = 1;
            end
        end
    end

Formula

A348268(a(n) - 1) = a(n).
A348268(a(n)*2^m - 1) = a(n)*2^m.
If A000040(m) = a(n) then A328596(m) = a(n) - 1;

A348369 Number of ways A328596(n) (the reversed binary expansion is an aperiodic necklace) can be expressed as sum A328596(k) + A328596(m) with 0 < k,m < n. The cases A328596(k) + A328596(m) and A328596(m) + A328596(k) are considered equal.

Original entry on oeis.org

0, 1, 1, 1, 2, 2, 2, 3, 2, 3, 4, 3, 4, 6, 3, 5, 5, 5, 5, 7, 5, 5, 9, 4, 6, 5, 8, 7, 9, 9, 7, 8, 10, 9, 9, 13, 6, 8, 8, 9, 15, 7, 10, 8, 14, 10, 12, 10, 11, 13, 13, 14, 14, 15, 16, 13, 14, 15, 15, 18, 14, 18, 16, 16, 22, 10, 9, 12, 12, 10, 24, 10, 16, 9, 21, 14, 20, 12
Offset: 1

Views

Author

Thomas Scheuerle, Oct 15 2021

Keywords

Comments

Conjecture: The only zero in this sequence is a(1). A348268 maps all terms of A328596 bijective to primes. Let P be this bijection between Lyndon words and primes and P' its inverse. Then for each prime q, there exist primes r and s such that q = P(P'(r) + P'(s)). If we were to define a table T(m,n) which encodes the sum q + 1 = (A000040(m) + A000040(n)), then q = P(P'(A000040(m)) + P'(A000040(n))) would be a permutation of this table; this connects this conjecture to Goldbach's conjecture.
All reversed binary expansions of powers of two are Lyndon words. All reversed binary expansions of numbers of the form 2*(2^m - 1) are Lyndon words, too. 2*(2^m - 1) + 2 is again a power of 2. Every positive integer can be expressed as a sum of powers of 2. From this we can conclude that it is always possible to compose terms of A328596(n) (n > 1), as a sum of terms of A328596. This would require at least 2 or more such terms.

Examples

			A328596(5) = A328596(2) + A328596(4) = A328596(3) + A328596(3) -> a(5) = 2.
.
Table A: A348268(A348268^-1(m) + A348268^-1(n))
      2   3   5   7
  -----------------
  2| (3)  4   6   8   prime numbers are marked by ()
  3|  4  (5) (7)(11)
  5|  6  (7)(11)  9
  7|  8 (11)  9 (13)
.
Table B: m + n
      2   3   5   7
  -----------------
  2| (4)  5   7   9   prime numbers + 1 are marked by ()
  3|  5  (6) (8) 10
  5|  7  (8) 10 (12)
  7|  9  10 (12)(14)
.
Table B is a permutation of Table A + 1.
		

Crossrefs

A275692 Numbers k such that every rotation of the binary digits of k is less than k.

Original entry on oeis.org

0, 1, 2, 4, 6, 8, 12, 14, 16, 20, 24, 26, 28, 30, 32, 40, 48, 50, 52, 56, 58, 60, 62, 64, 72, 80, 84, 96, 98, 100, 104, 106, 108, 112, 114, 116, 118, 120, 122, 124, 126, 128, 144, 160, 164, 168, 192, 194, 196, 200, 202, 208, 210, 212, 216, 218, 224, 226, 228
Offset: 1

Views

Author

Robert Israel, Aug 05 2016

Keywords

Comments

0, and terms of A065609 that are not in A121016.
Number of terms with d binary digits is A001037(d).
Take the binary representation of a(n), reverse it, add 1 to each digit. The result is the decimal representation of A102659(n).
From Gus Wiseman, Apr 19 2020: (Start)
Also numbers k such that the k-th composition in standard order (row k of A066099) is a Lyndon word. For example, the sequence of all Lyndon words begins:
0: () 52: (1,2,3) 118: (1,1,2,1,2)
1: (1) 56: (1,1,4) 120: (1,1,1,4)
2: (2) 58: (1,1,2,2) 122: (1,1,1,2,2)
4: (3) 60: (1,1,1,3) 124: (1,1,1,1,3)
6: (1,2) 62: (1,1,1,1,2) 126: (1,1,1,1,1,2)
8: (4) 64: (7) 128: (8)
12: (1,3) 72: (3,4) 144: (3,5)
14: (1,1,2) 80: (2,5) 160: (2,6)
16: (5) 84: (2,2,3) 164: (2,3,3)
20: (2,3) 96: (1,6) 168: (2,2,4)
24: (1,4) 98: (1,4,2) 192: (1,7)
26: (1,2,2) 100: (1,3,3) 194: (1,5,2)
28: (1,1,3) 104: (1,2,4) 196: (1,4,3)
30: (1,1,1,2) 106: (1,2,2,2) 200: (1,3,4)
32: (6) 108: (1,2,1,3) 202: (1,3,2,2)
40: (2,4) 112: (1,1,5) 208: (1,2,5)
48: (1,5) 114: (1,1,3,2) 210: (1,2,3,2)
50: (1,3,2) 116: (1,1,2,3) 212: (1,2,2,3)
(End)

Examples

			6 is in the sequence because its binary representation 110 is greater than all the rotations 011 and 101.
10 is not in the sequence because its binary representation 1010 is unchanged under rotation by 2 places.
From _Gus Wiseman_, Oct 31 2019: (Start)
The sequence of terms together with their binary expansions and binary indices begins:
    1:       1 ~ {1}
    2:      10 ~ {2}
    4:     100 ~ {3}
    6:     110 ~ {2,3}
    8:    1000 ~ {4}
   12:    1100 ~ {3,4}
   14:    1110 ~ {2,3,4}
   16:   10000 ~ {5}
   20:   10100 ~ {3,5}
   24:   11000 ~ {4,5}
   26:   11010 ~ {2,4,5}
   28:   11100 ~ {3,4,5}
   30:   11110 ~ {2,3,4,5}
   32:  100000 ~ {6}
   40:  101000 ~ {4,6}
   48:  110000 ~ {5,6}
   50:  110010 ~ {2,5,6}
   52:  110100 ~ {3,5,6}
   56:  111000 ~ {4,5,6}
   58:  111010 ~ {2,4,5,6}
(End)
		

Crossrefs

A similar concept is A328596.
Numbers whose binary expansion is aperiodic are A328594.
Numbers whose reversed binary expansion is a necklace are A328595.
Binary necklaces are A000031.
Binary Lyndon words are A001037.
Lyndon compositions are A059966.
Length of Lyndon factorization of binary expansion is A211100.
Length of co-Lyndon factorization of binary expansion is A329312.
Length of Lyndon factorization of reversed binary expansion is A329313.
Length of co-Lyndon factorization of reversed binary expansion is A329326.
All of the following pertain to compositions in standard order (A066099):
- Length is A000120.
- Necklaces are A065609.
- Sum is A070939.
- Rotational symmetries are counted by A138904.
- Strict compositions are A233564.
- Constant compositions are A272919.
- Lyndon compositions are A275692 (this sequence).
- Co-Lyndon compositions are A326774.
- Rotational period is A333632.
- Co-necklaces are A333764.
- Co-Lyndon factorizations are counted by A333765.
- Lyndon factorizations are counted by A333940.
- Reversed necklaces are A333943.

Programs

  • Maple
    filter:= proc(n) local L, k;
      L:= convert(convert(n,binary),string);
      for k from 1 to length(L)-1 do
        if lexorder(L,StringTools:-Rotate(L,k)) then return false fi;
      od;
      true
    end proc:
    select(filter, [$0..1000]);
  • Mathematica
    filterQ[n_] := Module[{bits, rr}, bits = IntegerDigits[n, 2]; rr = NestList[RotateRight, bits, Length[bits]-1] // Rest; AllTrue[rr, FromDigits[#, 2] < n&]];
    Select[Range[0, 1000], filterQ] (* Jean-François Alcover, Apr 29 2019 *)
  • Python
    def ok(n):
        b = bin(n)[2:]
        return all(b[i:] + b[:i] < b for i in range(1, len(b)))
    print([k for k in range(230) if ok(k)]) # Michael S. Branicky, May 26 2022

A328594 Numbers whose binary expansion is aperiodic.

Original entry on oeis.org

0, 1, 2, 4, 5, 6, 8, 9, 11, 12, 13, 14, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 32, 33, 34, 35, 37, 38, 39, 40, 41, 43, 44, 46, 47, 48, 49, 50, 51, 52, 53, 55, 56, 57, 58, 59, 60, 61, 62, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77
Offset: 1

Views

Author

Gus Wiseman, Oct 22 2019

Keywords

Comments

A finite sequence is aperiodic if all of its cyclic rotations are distinct. See A000740 or A027375 for details.
Also numbers k such that the k-th composition in standard order is aperiodic. The k-th composition in standard order (graded reverse-lexicographic, A066099) is obtained by taking the set of positions of 1's in the reversed binary expansion of k, prepending 0, taking first differences, and reversing again. This gives a bijective correspondence between nonnegative integers and integer compositions. - Gus Wiseman, Apr 28 2020

Examples

			The sequence of terms together with their binary expansions and binary indices begins:
   0:     0 ~ {}
   1:     1 ~ {1}
   2:    10 ~ {2}
   4:   100 ~ {3}
   5:   101 ~ {1,3}
   6:   110 ~ {2,3}
   8:  1000 ~ {4}
   9:  1001 ~ {1,4}
  11:  1011 ~ {1,2,4}
  12:  1100 ~ {3,4}
  13:  1101 ~ {1,3,4}
  14:  1110 ~ {2,3,4}
  16: 10000 ~ {5}
  17: 10001 ~ {1,5}
  18: 10010 ~ {2,5}
  19: 10011 ~ {1,2,5}
  20: 10100 ~ {3,5}
  21: 10101 ~ {1,3,5}
  22: 10110 ~ {2,3,5}
  23: 10111 ~ {1,2,3,5}
  24: 11000 ~ {4,5}
		

Crossrefs

The complement is A121016.
The version for prime indices is A085971.
Numbers without proper integer roots are A007916.
Necklaces are A328595.
Lyndon words are A328596.
Aperiodic compositions are A000740.
Aperiodic binary sequences are A027375.

Programs

  • Mathematica
    aperQ[q_]:=Array[RotateRight[q,#]&,Length[q],1,UnsameQ];
    Select[Range[0,100],aperQ[IntegerDigits[#,2]]&]

A102659 List of Lyndon words on {1,2} sorted first by length and then lexicographically.

Original entry on oeis.org

1, 2, 12, 112, 122, 1112, 1122, 1222, 11112, 11122, 11212, 11222, 12122, 12222, 111112, 111122, 111212, 111222, 112122, 112212, 112222, 121222, 122222, 1111112, 1111122, 1111212, 1111222, 1112112, 1112122, 1112212, 1112222, 1121122
Offset: 1

Views

Author

N. J. A. Sloane, Feb 03 2005

Keywords

Comments

A Lyndon word is primitive (not a power of another word) and is earlier in lexicographic order than any of its cyclic shifts.

Crossrefs

The "co" version is A329318.
A triangular version is A296657.
A sequence listing all Lyndon compositions is A294859.
Numbers whose binary expansion is Lyndon are A328596.
Length of the Lyndon factorization of the binary expansion is A211100.

Programs

  • Haskell
    cf. link.
    
  • Mathematica
    lynQ[q_]:=Array[Union[{q,RotateRight[q,#]}]=={q,RotateRight[q,#]}&,Length[q]-1,1,And];
    Join@@Table[FromDigits/@Select[Tuples[{1,2},n],lynQ],{n,5}] (* Gus Wiseman, Nov 14 2019 *)
  • PARI
    is_A102659(n)={ vecsort(d=digits(n))!=d&&for(i=1,#d-1, n>[1,10^(#d-i)]*divrem(n,10^i)&&return); fordiv(#d,L,L<#d && d==concat(Col(vector(#d/L,i,1)~*vecextract(d,2^L-1))~)&&return); !setminus(Set(d),[1,2])} \\ The last check is the least expensive one, but not useful if we test only numbers with digits {1,2}.
    for(n=1,6,p=vector(n,i,10^(n-i))~;forvec(d=vector(n,i,[1,2]),is_A102659(m=d*p)&&print1(m","))) \\ One could use is_A102660 instead of is_A102659 here. - M. F. Hasler, Mar 08 2014

Formula

A102659 = A102660 intersect A007931 = A213969 intersect A239016. - M. F. Hasler, Mar 10 2014

Extensions

More terms from Franklin T. Adams-Watters, Dec 14 2006
Definition improved by Reinhard Zumkeller, Mar 23 2012

A211100 Number of factors in Lyndon factorization of binary expansion of n.

Original entry on oeis.org

1, 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 2, 4, 3, 4, 4, 5, 2, 3, 2, 4, 3, 3, 2, 5, 3, 4, 3, 5, 4, 5, 5, 6, 2, 3, 2, 4, 2, 3, 2, 5, 3, 4, 2, 4, 3, 3, 2, 6, 3, 4, 3, 5, 4, 4, 3, 6, 4, 5, 4, 6, 5, 6, 6, 7, 2, 3, 2, 4, 2, 3, 2, 5, 3, 3, 2, 4, 2, 3, 2, 6, 3, 4, 3, 5, 4, 3, 2, 5, 3, 4, 3, 4, 3, 3, 2, 7, 3, 4, 3, 5, 3, 4, 3, 6, 4, 5, 3, 5, 4, 4, 3, 7, 4, 5, 4, 6, 5, 5, 4, 7
Offset: 0

Views

Author

N. J. A. Sloane, Mar 31 2012

Keywords

Comments

Any binary word has a unique factorization as a product of nonincreasing Lyndon words (see Lothaire). a(n) = number of factors in Lyndon factorization of binary expansion of n.
It appears that a(n) = k for the first time when n = 2^(k-1)+1.
We define the Lyndon product of two or more finite sequences to be the lexicographically maximal sequence obtainable by shuffling the sequences together. For example, the Lyndon product of (231) with (213) is (232131), the product of (221) with (213) is (222131), and the product of (122) with (2121) is (2122121). A Lyndon word is a finite sequence that is prime with respect to the Lyndon product. Equivalently, a Lyndon word is a finite sequence that is lexicographically strictly less than all of its cyclic rotations. Every finite sequence has a unique (orderless) factorization into Lyndon words, and if these factors are arranged in lexicographically decreasing order, their concatenation is equal to their Lyndon product. - Gus Wiseman, Nov 12 2019

Examples

			n=25 has binary expansion 11001, which has Lyndon factorization (1)(1)(001) with three factors, so a(25) = 3.
Here are the Lyndon factorizations for small values of n:
.0.
.1.
.1.0.
.1.1.
.1.0.0.
.1.01.
.1.1.0.
.1.1.1.
.1.0.0.0.
.1.001.
.1.01.0.
.1.011.
.1.1.0.0.
...
		

References

  • M. Lothaire, Combinatorics on Words, Addison-Wesley, Reading, MA, 1983. See Theorem 5.1.5, p. 67.
  • G. Melançon, Factorizing infinite words using Maple, MapleTech Journal, vol. 4, no. 1, 1997, pp. 34-42

Crossrefs

Cf. A001037 (number of Lyndon words of length m); A102659 (list thereof).
A211095 and A211096 give information about the smallest (or rightmost) factor. Cf. A211097, A211098, A211099.
Row-lengths of A329314.
The "co-" version is A329312.
Positions of 2's are A329327.
The reversed version is A329313.
The inverted version is A329312.
Ignoring the first digit gives A211097.

Programs

  • Mathematica
    lynQ[q_]:=Array[Union[{q,RotateRight[q,#]}]=={q,RotateRight[q,#]}&,Length[q]-1,1,And];
    lynfac[q_]:=If[Length[q]==0,{},Function[i,Prepend[lynfac[Drop[q,i]],Take[q,i]]][Last[Select[Range[Length[q]],lynQ[Take[q,#]]&]]]];
    Table[Length[lynfac[IntegerDigits[n,2]]],{n,0,30}] (* Gus Wiseman, Nov 12 2019 *)

A328592 Numbers whose binary expansion has all different lengths of runs of 1's.

Original entry on oeis.org

0, 1, 2, 3, 4, 6, 7, 8, 11, 12, 13, 14, 15, 16, 19, 22, 23, 24, 25, 26, 28, 29, 30, 31, 32, 35, 38, 39, 44, 46, 47, 48, 49, 50, 52, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 67, 70, 71, 76, 78, 79, 88, 92, 94, 95, 96, 97, 98, 100, 103, 104, 110, 111, 112, 113, 114
Offset: 1

Views

Author

Gus Wiseman, Oct 20 2019

Keywords

Comments

Also numbers whose binary indices have different lengths of runs of successive parts. A binary index of n is any position of a 1 in its reversed binary expansion. The binary indices of n are row n of A048793.
The complement is {5, 9, 10, 17, 18, 20, 21, 27, ...}.

Examples

			The sequence of terms together with their binary expansions and binary indices begins:
   0:     0 ~ {}
   1:     1 ~ {1}
   2:    10 ~ {2}
   3:    11 ~ {1,2}
   4:   100 ~ {3}
   6:   110 ~ {2,3}
   7:   111 ~ {1,2,3}
   8:  1000 ~ {4}
  11:  1011 ~ {1,2,4}
  12:  1100 ~ {3,4}
  13:  1101 ~ {1,3,4}
  14:  1110 ~ {2,3,4}
  15:  1111 ~ {1,2,3,4}
  16: 10000 ~ {5}
  19: 10011 ~ {1,2,5}
  22: 10110 ~ {2,3,5}
  23: 10111 ~ {1,2,3,5}
  24: 11000 ~ {4,5}
  25: 11001 ~ {1,4,5}
  26: 11010 ~ {2,4,5}
		

Crossrefs

The version for prime indices is A130091.
The binary expansion of n has A069010(n) runs of 1's.
The lengths of runs of 1's in the binary expansion of n are row n of A245563.
Numbers whose binary expansion has equal lengths of runs of 1's are A164707.

Programs

  • Mathematica
    Select[Range[0,100],UnsameQ@@Length/@Split[Join@@Position[Reverse[IntegerDigits[#,2]],1],#2==#1+1&]&]

A328595 Numbers whose reversed binary expansion is a necklace.

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, 44, 48, 52, 54, 56, 58, 60, 62, 63, 64, 72, 80, 84, 88, 92, 96, 100, 104, 106, 108, 112, 116, 118, 120, 122, 124, 126, 127, 128, 136, 144, 152, 160, 164, 168, 170, 172, 176, 180
Offset: 1

Views

Author

Gus Wiseman, Oct 22 2019

Keywords

Comments

A necklace is a finite sequence that is lexicographically minimal among all of its cyclic rotations.

Examples

			The sequence of terms together with their binary expansions and binary indices begins:
   1:      1 ~ {1}
   2:     10 ~ {2}
   3:     11 ~ {1,2}
   4:    100 ~ {3}
   6:    110 ~ {2,3}
   7:    111 ~ {1,2,3}
   8:   1000 ~ {4}
  10:   1010 ~ {2,4}
  12:   1100 ~ {3,4}
  14:   1110 ~ {2,3,4}
  15:   1111 ~ {1,2,3,4}
  16:  10000 ~ {5}
  20:  10100 ~ {3,5}
  24:  11000 ~ {4,5}
  26:  11010 ~ {2,4,5}
  28:  11100 ~ {3,4,5}
  30:  11110 ~ {2,3,4,5}
  31:  11111 ~ {1,2,3,4,5}
  32: 100000 ~ {6}
  36: 100100 ~ {3,6}
		

Crossrefs

A similar concept is A065609.
The version with the most significant digit ignored is A328607.
Lyndon words are A328596.
Aperiodic words are A328594.
Binary necklaces are A000031.
Necklace compositions are A008965.

Programs

  • Mathematica
    neckQ[q_]:=Array[OrderedQ[{q,RotateRight[q,#]}]&,Length[q]-1,1,And];
    Select[Range[100],neckQ[Reverse[IntegerDigits[#,2]]]&]
  • Python
    from itertools import count, islice
    from sympy.utilities.iterables import necklaces
    def a_gen():
        for n in count(1):
            t = []
            for i in necklaces(n,2):
                if sum(i)>0:
                    t.append(sum(2**j for j in range(len(i)) if i[j] > 0))
            yield from sorted(t)
    A328595_list = list(islice(a_gen(), 100)) # John Tyler Rascoe, May 24 2024

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

A164707 A positive integer n is included if all runs of 1's in binary n are of the same length.

Original entry on oeis.org

1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 14, 15, 16, 17, 18, 20, 21, 24, 27, 28, 30, 31, 32, 33, 34, 36, 37, 40, 41, 42, 48, 51, 54, 56, 60, 62, 63, 64, 65, 66, 68, 69, 72, 73, 74, 80, 81, 82, 84, 85, 96, 99, 102, 108, 112, 119, 120, 124, 126, 127, 128, 129, 130, 132, 133, 136
Offset: 1

Views

Author

Leroy Quet, Aug 23 2009

Keywords

Comments

Clarification: A binary number consists of "runs" completely of 1's alternating with runs completely of 0's. No two or more runs all of the same digit are adjacent.
This sequence contains in part positive integers that each contain one run of 1's. For those members of this sequence each with at least two runs of 1's, see A164709.

Examples

			From _Gus Wiseman_, Oct 31 2019: (Start)
The sequence of terms together with their binary expansions and binary indices begins:
   1:      1 ~ {1}
   2:     10 ~ {2}
   3:     11 ~ {1,2}
   4:    100 ~ {3}
   5:    101 ~ {1,3}
   6:    110 ~ {2,3}
   7:    111 ~ {1,2,3}
   8:   1000 ~ {4}
   9:   1001 ~ {1,4}
  10:   1010 ~ {2,4}
  12:   1100 ~ {3,4}
  14:   1110 ~ {2,3,4}
  15:   1111 ~ {1,2,3,4}
  16:  10000 ~ {5}
  17:  10001 ~ {1,5}
  18:  10010 ~ {2,5}
  20:  10100 ~ {3,5}
  21:  10101 ~ {1,3,5}
  24:  11000 ~ {4,5}
  27:  11011 ~ {1,2,4,5}
(End)
		

Crossrefs

The version for prime indices is A072774.
The binary expansion of n has A069010(n) runs of 1's.
Numbers whose runs are all of different lengths are A328592.
Partitions with equal multiplicities are A047966.
Numbers whose binary expansion is aperiodic are A328594.
Numbers whose reversed binary expansion is a necklace are A328595.
Numbers whose reversed binary expansion is a Lyndon word are A328596.

Programs

  • Maple
    isA164707 := proc(n) local bdg,arl,lset ; bdg := convert(n,base,2) ; lset := {} ; arl := -1 ; for p from 1 to nops(bdg) do if op(p,bdg) = 1 then if p = 1 then arl := 1 ; else arl := arl+1 ; end if; else if arl > 0 then lset := lset union {arl} ; end if; arl := 0 ; end if; end do ; if arl > 0 then lset := lset union {arl} ; end if; return (nops(lset) <= 1 ); end proc: for n from 1 to 300 do if isA164707(n) then printf("%d,",n) ; end if; end do; # R. J. Mathar, Feb 27 2010
  • Mathematica
    Select[Range@ 140, SameQ @@ Map[Length, Select[Split@ IntegerDigits[#, 2], First@ # == 1 &]] &] (* Michael De Vlieger, Aug 20 2017 *)
  • Perl
    foreach(1..140){
        %runs=();
        $runs{$}++ foreach split /0+/, sprintf("%b",$);
        print "$_, " if 1==keys(%runs);
    }
    # Ivan Neretin, Nov 09 2015

Extensions

Extended beyond 42 by R. J. Mathar, Feb 27 2010
Showing 1-10 of 67 results. Next