OFFSET
0,1
COMMENTS
Consider the infinite string 011011100101110111100010011010... (cf. A030190) formed by the concatenation of all binary digits of all nonnegative numbers. From the position of the first digit of the binary representation of n, where n starts as its natural position in the string, find the number of digits one has to move forward to get to the start of the second occurrence of n. This is a(n).
LINKS
Michael S. Branicky, Table of n, a(n) for n = 0..16383
Scott R. Shannon, Image of the first 100000 terms.
FORMULA
From Michael S. Branicky, Sep 16 2022: (Start)
a(2^k-1) = 1, for k >= 1;
a(2^k) = (k+1)*2^k, for k >= 0. (End)
EXAMPLE
a(0) = 3 as '0' starts at position 1 and appears again at position 4.
a(1) = 1 as '1' starts at position 2 and appears again at position 3.
a(4) = 12 as '100' starts at position 7 and appears again at position 19.
a(7) = 1 as '111' starts at position 16 and appears again at position 17.
a(8) = 32 as '1000' starts at position 19 and appears again at position 51.
PROG
(Python)
def a(n):
b = s = bin(n)[2:]
while s.find(b, 1) < 0: n += 1; s += bin(n)[2:]
return s.find(b, 1)
print([a(n) for n in range(76)]) # Michael S. Branicky, Sep 16 2022
CROSSREFS
KEYWORD
nonn,base
AUTHOR
Scott R. Shannon, Feb 19 2021
STATUS
approved