login
A171916
Van Eck's sequence (cf. A181391) starting with a(1) = 6.
1
6, 0, 0, 1, 0, 2, 0, 2, 2, 1, 6, 10, 0, 6, 3, 0, 3, 2, 9, 0, 4, 0, 2, 5, 0, 3, 9, 8, 0, 4, 9, 4, 2, 10, 22, 0, 7, 0, 2, 6, 26, 0, 4, 11, 0, 3, 20, 0, 3, 3, 1, 41, 0, 5, 30, 0, 3, 7, 21, 0, 4, 18, 0, 3, 7, 7, 1, 16, 0, 6, 30, 16, 4, 12, 0, 6, 6, 1, 11, 35, 0, 6, 5, 29, 0, 4, 13, 0, 3, 25, 0
OFFSET
1,1
COMMENTS
Van Eck's sequence is defined by a(n+1) = min { k > 0 | a(n-k) = a(n) } or 0 if this set is empty, i.e., a(n) does not appear earlier in the sequence. - M. F. Hasler, Jun 15 2019
PROG
(PARI) A171916_vec(N, a=6, 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 15 2019
(Python)
from itertools import count, islice
def A171916gen(): # generator of terms
b, bdict = 6, {6:(1, )}
for n in count(2):
yield b
if len(l := bdict[b]) > 1:
b = n-1-l[-2]
else:
b = 0
if b in bdict:
bdict[b] = (bdict[b][-1], n)
else:
bdict[b] = (n, )
A171916_list = list(islice(A171916gen(), 20)) # Chai Wah Wu, Dec 21 2021
CROSSREFS
Cf. A181391, A171911, ..., A171918 (same but starting with 0, 1, ..., 8).
Sequence in context: A343956 A324878 A324398 * A372192 A372047 A325740
KEYWORD
nonn
AUTHOR
N. J. A. Sloane, Oct 22 2010
EXTENSIONS
Name edited and cross-references added by M. F. Hasler, Jun 15 2019
STATUS
approved