login
For any number m, let m* be the bi-infinite string obtained by repetition of the binary expansion of m; a(n) is the least k such that the binary expansion of n appears in k*.
2

%I #16 Jun 28 2024 09:30:19

%S 1,2,1,4,2,5,1,8,4,2,5,9,5,11,1,16,8,4,9,18,2,5,11,17,9,21,5,19,11,23,

%T 1,32,16,8,17,4,18,9,19,34,18,2,21,37,5,11,23,33,17,37,9,38,21,5,11,

%U 35,19,43,11,39,23,47,1,64,32,16,33,8,34,17,35,68,4

%N For any number m, let m* be the bi-infinite string obtained by repetition of the binary expansion of m; a(n) is the least k such that the binary expansion of n appears in k*.

%H Rémy Sigrist, <a href="/A373399/b373399.txt">Table of n, a(n) for n = 1..8191</a>

%H Rémy Sigrist, <a href="/A373399/a373399.gp.txt">PARI program</a>

%H <a href="/index/Bi#binary">Index entries for sequences related to binary expansion of n</a>

%F a(n) <= n with equality iff n is a power of 2.

%F a(2^k - 1) = 1 for any k > 0.

%e The first terms, in decimal and in binary, are:

%e n a(n) bin(n) bin(a(n))

%e -- ---- ------ ---------

%e 1 1 1 1

%e 2 2 10 10

%e 3 1 11 1

%e 4 4 100 100

%e 5 2 101 10

%e 6 5 110 101

%e 7 1 111 1

%e 8 8 1000 1000

%e 9 4 1001 100

%e 10 2 1010 10

%e 11 5 1011 101

%e 12 9 1100 1001

%e 13 5 1101 101

%e 14 11 1110 1011

%e 15 1 1111 1

%e 16 16 10000 10000

%o (PARI) \\ See Links section.

%o (Python)

%o def a(n):

%o target = bin(n)[2:]

%o for m in range(1, n):

%o b = bin(m)[2:]

%o mstar = b*(2*len(target)//len(b))

%o if target in mstar:

%o return m

%o return n

%o print([a(n) for n in range(1, 74)]) # _Michael S. Branicky_, Jun 14 2024

%Y Cf. A326774, A361942, A373553.

%K nonn,base

%O 1,2

%A _Rémy Sigrist_, Jun 04 2024