login
A342303
a(0) = 1; for n >= 1, a(n) = the decimal value of the binary number of the total binary digits back from the end of the concatenation of all previous binary terms where the binary value of n last appeared. If the binary value of n has not previously appeared then a(n) = 0.
4
1, 1, 0, 3, 0, 5, 6, 4, 0, 0, 7, 14, 0, 16, 10, 15, 13, 0, 21, 0, 39, 10, 58, 8, 0, 49, 16, 81, 68, 36, 49, 72, 0, 39, 33, 25, 25, 0, 40, 16, 11, 106, 6, 7, 0, 9, 10, 26, 60, 85, 11, 70, 40, 9, 214, 30, 32, 52, 16, 0, 65, 30, 6, 226, 0, 24, 130, 161, 20, 0, 99, 0, 68, 216, 136, 0, 62, 26, 129
OFFSET
0,4
COMMENTS
The longest run of 0 terms, corresponding to binary values that have not previously appeared, for n up to 100000 is four, starting at n = 512. Not all powers of 2 are 0 as it may have appeared as a previous value's offset, e.g., a(65536) = 412323.
EXAMPLE
a(1) = 1 as the binary string concatenation up to a(0) = '1', and the binary value of 1 is '1' which appears 1 (1_2) digit back from the end of the string.
a(2) = 0 as the binary string concatenation up to a(1) = '11', while the binary value of 2 is '10' which does not appear in the string.
a(3) = 3 as the binary string concatenation up to a(2) = '110', and the binary value of 3 is '11' which appears 3 (11_2) digits back from the end of the string.
a(5) = 5 as the binary string concatenation up to a(4) = '110110', and the binary value of 5 is '101' which appears 5 (101_2) digits back from the end of the string.
a(10) = 7 as the binary string concatenation up to a(9) = '11011010111010000', and the binary value of 10 is '1010' which appears 7 (111_2) digits back from the end of the string.
PROG
(Python)
from itertools import count, islice
def agen():
b = "1"
yield 1
for k in count(1):
bk = bin(k)[2:]
idx = b.rfind(bk)
if idx == -1:
yield 0
b += "0"
else:
yield len(b) - idx
b += bin(len(b) - idx)[2:]
print(list(islice(agen(), 79))) # Michael S. Branicky, Mar 18 2022
CROSSREFS
KEYWORD
nonn,base
AUTHOR
Scott R. Shannon, Mar 07 2021
STATUS
approved