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.

A171912 Van Eck sequence (cf. A181391) starting with 2.

This page as a plain text file.
%I A171912 #20 Dec 21 2021 12:19:47
%S A171912 2,0,0,1,0,2,5,0,3,0,2,5,5,1,10,0,6,0,2,8,0,3,13,0,3,3,1,13,5,16,0,7,
%T A171912 0,2,15,0,3,11,0,3,3,1,15,8,24,0,7,15,5,20,0,5,3,12,0,4,0,2,24,14,0,4,
%U A171912 6,46,0,4,4,1,26,0,5,19,0,3,21,0,3,3,1,11,42,0,6,20,34,0,4,20,4
%N A171912 Van Eck sequence (cf. A181391) starting with 2.
%C A171912 A van Eck sequence is defined recursively by a(n+1) = min { k > 0 | a(n-k) = a(n) } or 0 if this set is empty. - _M. F. Hasler_, Jun 12 2019
%t A171912 t = {2};
%t A171912 Do[
%t A171912 d = Quiet[Check[Position[t, Last[t]][[-2]][[1]], 0]];
%t A171912 If[d == 0, x = 0, x = Length[t] - d];
%t A171912 AppendTo[t, x], 100]
%t A171912 t  (* _Horst H. Manninger_, Aug 30 2020 *)
%o A171912 (PARI) A171912_vec(N, a=2, i=Map())={vector(N, n, a=if(n>1, iferr(n-mapget(i, a), E, 0)+mapput(i, a, n), a))} \\ _M. F. Hasler_, Jun 11 2019
%o A171912 (Python)
%o A171912 from itertools import count, islice
%o A171912 def A171912gen(): # generator of terms
%o A171912     b, bdict = 2, {2:(1,)}
%o A171912     for n in count(2):
%o A171912         yield b
%o A171912         if len(l := bdict[b]) > 1:
%o A171912             b = n-1-l[-2]
%o A171912         else:
%o A171912             b = 0
%o A171912         if b in bdict:
%o A171912             bdict[b] = (bdict[b][-1],n)
%o A171912         else:
%o A171912             bdict[b] = (n,)
%o A171912 A171912_list = list(islice(A171912gen(),20)) # _Chai Wah Wu_, Dec 21 2021
%Y A171912 Cf. A181391, A171911, ..., A171918 (same but starting with 0, 1, ..., 8).
%K A171912 nonn
%O A171912 1,1
%A A171912 _N. J. A. Sloane_, Oct 22 2010
%E A171912 Name edited and cross-references added by _M. F. Hasler_, Jun 12 2019