OFFSET
1,2
COMMENTS
Binary version of the concept behind A358180.
EXAMPLE
First terms written in binary, substituting "." for 0 to enhance the pattern of 1's.
n a(n) a(n)_2
-------------------------------------
1 1 1
2 5 1.1
3 10 1.1.
4 24 11...
5 41 1.1..1
6 52 11.1..
7 152 1..11...
8 162 1.1...1.
9 364 1.11.11..
10 726 1.11.1.11.
11 1150 1...111111.
12 2451 1..11..1..11
13 4626 1..1....1..1.
14 9847 1..11..111.111
15 18131 1...11.11.1..11
16 36016 1...11..1.11....
17 71709 1...11......111.1
18 143848 1...11...1111.1...
19 276769 1....111..1..1....1
20 551730 1....11.1.11..11..1.
21 1086371 1....1..1..111.1...11
22 2158296 1.....111.111.11.11...
23 4297353 1.....11..1..1.1...1..1
24 8607525 1.....11.1.1.111..1..1.1
etc.
MATHEMATICA
nn = 2^20; q[_] = False; q[0] = True; a[_] = 0; c[_] = -1; c[0] = 2; m = 1; {1}~Join~Rest@ Reap[Do[j = c[m]; k = m; c[m] = n; m = 0; If[j > 0, m = n - j]; If[! q[#], Sow[n]; q[#] = True] & @ IntegerLength[k, 2], {n, 3, nn}] ][[-1, -1]]
PROG
(Python)
from itertools import count
def A358259(n):
b, bdict, k = 0, {0:(1, )}, 1<<n-1 if n > 1 else 0
for m in count(2):
if b >= k:
return m-1
if len(l := bdict[b]) > 1:
b = m-1-l[-2]
if b in bdict:
bdict[b] = (bdict[b][-1], m)
else:
bdict[b] = (m, )
else:
b = 0
bdict[0] = (bdict[0][-1], m) # Chai Wah Wu, Nov 06 2022
CROSSREFS
KEYWORD
nonn,base
AUTHOR
Michael De Vlieger, Nov 05 2022
EXTENSIONS
a(30)-a(34) from Chai Wah Wu, Nov 06 2022
a(35) from Martin Ehrenstein, Nov 07 2022
STATUS
approved