A373399 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*.
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, 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, 35, 19, 43, 11, 39, 23, 47, 1, 64, 32, 16, 33, 8, 34, 17, 35, 68, 4
Offset: 1
Examples
The first terms, in decimal and in binary, are: n a(n) bin(n) bin(a(n)) -- ---- ------ --------- 1 1 1 1 2 2 10 10 3 1 11 1 4 4 100 100 5 2 101 10 6 5 110 101 7 1 111 1 8 8 1000 1000 9 4 1001 100 10 2 1010 10 11 5 1011 101 12 9 1100 1001 13 5 1101 101 14 11 1110 1011 15 1 1111 1 16 16 10000 10000
Links
- Rémy Sigrist, Table of n, a(n) for n = 1..8191
- Rémy Sigrist, PARI program
- Index entries for sequences related to binary expansion of n
Programs
-
PARI
\\ See Links section.
-
Python
def a(n): target = bin(n)[2:] for m in range(1, n): b = bin(m)[2:] mstar = b*(2*len(target)//len(b)) if target in mstar: return m return n print([a(n) for n in range(1, 74)]) # Michael S. Branicky, Jun 14 2024
Formula
a(n) <= n with equality iff n is a power of 2.
a(2^k - 1) = 1 for any k > 0.