cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

A358259 Positions of the first n-bit number to appear in Van Eck's sequence (A181391).

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