login
Numbers whose reversed binary expansion is a necklace.
44

%I #16 May 24 2024 16:22:37

%S 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,

%T 54,56,58,60,62,63,64,72,80,84,88,92,96,100,104,106,108,112,116,118,

%U 120,122,124,126,127,128,136,144,152,160,164,168,170,172,176,180

%N Numbers whose reversed binary expansion is a necklace.

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

%H John Tyler Rascoe, <a href="/A328595/b328595.txt">Table of n, a(n) for n = 1..10000</a>

%e The sequence of terms together with their binary expansions and binary indices begins:

%e 1: 1 ~ {1}

%e 2: 10 ~ {2}

%e 3: 11 ~ {1,2}

%e 4: 100 ~ {3}

%e 6: 110 ~ {2,3}

%e 7: 111 ~ {1,2,3}

%e 8: 1000 ~ {4}

%e 10: 1010 ~ {2,4}

%e 12: 1100 ~ {3,4}

%e 14: 1110 ~ {2,3,4}

%e 15: 1111 ~ {1,2,3,4}

%e 16: 10000 ~ {5}

%e 20: 10100 ~ {3,5}

%e 24: 11000 ~ {4,5}

%e 26: 11010 ~ {2,4,5}

%e 28: 11100 ~ {3,4,5}

%e 30: 11110 ~ {2,3,4,5}

%e 31: 11111 ~ {1,2,3,4,5}

%e 32: 100000 ~ {6}

%e 36: 100100 ~ {3,6}

%t neckQ[q_]:=Array[OrderedQ[{q,RotateRight[q,#]}]&,Length[q]-1,1,And];

%t Select[Range[100],neckQ[Reverse[IntegerDigits[#,2]]]&]

%o (Python)

%o from itertools import count, islice

%o from sympy.utilities.iterables import necklaces

%o def a_gen():

%o for n in count(1):

%o t = []

%o for i in necklaces(n,2):

%o if sum(i)>0:

%o t.append(sum(2**j for j in range(len(i)) if i[j] > 0))

%o yield from sorted(t)

%o A328595_list = list(islice(a_gen(), 100)) # _John Tyler Rascoe_, May 24 2024

%Y A similar concept is A065609.

%Y The version with the most significant digit ignored is A328607.

%Y Lyndon words are A328596.

%Y Aperiodic words are A328594.

%Y Binary necklaces are A000031.

%Y Necklace compositions are A008965.

%Y Cf. A000120, A000740, A001037, A032153, A059966, A275692, A328668.

%K nonn,base

%O 1,2

%A _Gus Wiseman_, Oct 22 2019