OFFSET
1,5
COMMENTS
After the initial value, the sequence is extended by a(n+1) = min { k > 0: a(n-k) = a(n) } or 0 if no such k exists, i.e., if a(n) did not appear earlier.
LINKS
Chai Wah Wu, Table of n, a(n) for n = 1..10001
MATHEMATICA
t = {1};
Do[
d = Quiet[Check[Position[t, Last[t]][[-2]][[1]], 0], Part::partw];
If[d == 0, x = 0, x = Length[t] - d];
AppendTo[t, x], 100]
t (* Horst H. Manninger, Aug 03 2020 *)
PROG
(Python)
A171911_list, l = [1, 0], 0
for n in range(1, 10**4):
for m in range(n-1, -1, -1):
if A171911_list[m] == l:
l = n-m
break
else: # break did not occur
l = 0
A171911_list.append(l) # Chai Wah Wu, Jan 02 2015
(PARI) A171911_vec(N, a=1, 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
CROSSREFS
KEYWORD
nonn
AUTHOR
N. J. A. Sloane, Oct 22 2010
EXTENSIONS
Edited by M. F. Hasler, Jun 11 2019
STATUS
approved