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.

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