login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A358258 First n-bit number to appear in Van Eck's sequence (A181391). 2

%I #21 Nov 07 2022 02:10:12

%S 0,2,6,9,17,42,92,131,307,650,1024,2238,4164,8226,17384,33197,67167,

%T 133549,269119,525974,1055175,2111641,4213053,8444257,16783217,

%U 33601813,67405064,134239260,268711604,538400994,1076155844,2152693259,4299075300,8594396933,17203509931

%N First n-bit number to appear in Van Eck's sequence (A181391).

%C Binary version of A358168.

%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 0 .

%e 2 2 1.

%e 3 6 11.

%e 4 9 1..1

%e 5 17 1...1

%e 6 42 1.1.1.

%e 7 92 1.111..

%e 8 131 1.....11

%e 9 307 1..11..11

%e 10 650 1.1...1.1.

%e 11 1024 1..........

%e 12 2238 1...1.11111.

%e 13 4164 1.....1...1..

%e 14 8226 1.......1...1.

%e 15 17384 1....11111.1...

%e 16 33197 1......11.1.11.1

%e 17 67167 1.....11..1.11111

%e 18 133549 1.....1..11.1.11.1

%e 19 269119 1.....11.11..111111

%e 20 525974 1........11.1..1.11.

%e 21 1055175 1.......11..111...111

%e 22 2111641 1.......111...1..11..1

%e 23 4213053 1.......1..1..1..1111.1

%e 24 8444257 1.......11.11..1.11....1

%t nn = 2^20; q[_] = False; q[0] = True; a[_] = 0; c[_] = -1; c[0] = 2; m = 1; {0}~Join~Rest@ Reap[Do[j = c[m]; k = m; c[m] = n; m = 0; If[j > 0, m = n - j]; If[! q[#], Sow[k]; q[#] = True] & @ IntegerLength[k, 2], {n, 3, nn}] ][[-1, -1]]

%o (Python)

%o from itertools import count

%o def A358258(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 b

%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, A358259.

%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

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified September 7 08:36 EDT 2024. Contains 375730 sequences. (Running on oeis4.)