Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).
%I #21 Nov 07 2022 02:10:07
%S 1,5,10,24,41,52,152,162,364,726,1150,2451,4626,9847,18131,36016,
%T 71709,143848,276769,551730,1086371,2158296,4297353,8607525,17159741,
%U 34152001,68194361,136211839,271350906,541199486,1084811069,2165421369,4331203801,8643518017,17303787585
%N Positions of the first n-bit number to appear in Van Eck's sequence (A181391).
%C Binary version of the concept behind A358180.
%e First terms written in binary, substituting "." for 0 to enhance the pattern of 1's.
%e n a(n) a(n)_2
%e -------------------------------------
%e 1 1 1
%e 2 5 1.1
%e 3 10 1.1.
%e 4 24 11...
%e 5 41 1.1..1
%e 6 52 11.1..
%e 7 152 1..11...
%e 8 162 1.1...1.
%e 9 364 1.11.11..
%e 10 726 1.11.1.11.
%e 11 1150 1...111111.
%e 12 2451 1..11..1..11
%e 13 4626 1..1....1..1.
%e 14 9847 1..11..111.111
%e 15 18131 1...11.11.1..11
%e 16 36016 1...11..1.11....
%e 17 71709 1...11......111.1
%e 18 143848 1...11...1111.1...
%e 19 276769 1....111..1..1....1
%e 20 551730 1....11.1.11..11..1.
%e 21 1086371 1....1..1..111.1...11
%e 22 2158296 1.....111.111.11.11...
%e 23 4297353 1.....11..1..1.1...1..1
%e 24 8607525 1.....11.1.1.111..1..1.1
%e etc.
%t 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]]
%o (Python)
%o from itertools import count
%o def A358259(n):
%o b, bdict, k = 0, {0:(1,)},1<<n-1 if n > 1 else 0
%o for m in count(2):
%o if b >= k:
%o return m-1
%o if len(l := bdict[b]) > 1:
%o b = m-1-l[-2]
%o if b in bdict:
%o bdict[b] = (bdict[b][-1],m)
%o else:
%o bdict[b] = (m,)
%o else:
%o b = 0
%o bdict[0] = (bdict[0][-1],m) # _Chai Wah Wu_, Nov 06 2022
%Y Cf. A181391, A358168, A358180, A358258.
%K nonn,base
%O 1,2
%A _Michael De Vlieger_, Nov 05 2022
%E a(30)-a(34) from _Chai Wah Wu_, Nov 06 2022
%E a(35) from _Martin Ehrenstein_, Nov 07 2022