OFFSET
0,6
COMMENTS
In other words, if the last term a(n) has not appeared previously, subtract the term a(n - a(n)) from a(n) to get the next term. Otherwise, count the terms equal to the last term a(n) in a(0..n-1) to get the next term.
This sequence has no repeating pattern because of the rule a(n+1) = a(n) - a(n - a(n)).
A new record in the sequence is always the previous record + 1. Therefore all terms are >= 0.
LINKS
Robert Israel, Table of n, a(n) for n = 0..10000
EXAMPLE
a(0)=0 (given).
a(1)=0 (given).
a(2)=1: a(1)=0 is a term of a(0..0), therefore a(2) = Number of terms=0 in a(0..0) = 1.
a(3)=1: a(2)=1 is not a term of a(0..1), therefore: a(3) = a(2) - a(2 - 1) = 1 - 0 = 1.
a(4)=1: a(3)=1 is a term of a(0..2), therefore a(4) = Number of terms=1 in a(0..2) = 1.
a(5)=2: a(4)=1 is a term of a(0..3), therefore a(5) = Number of terms=1 in a(0..3) = 2.
a(6)=1: a(5)=2 is not a term of a(0..4), therefore: a(6) = a(5) - a(5 - 2) = 2 - 1 = 1.
MAPLE
R:= [0, 0]:
for n from 2 to 100 do
q:= numboccur(R[-1], R[1..-2]);
if q = 0 then R:= [op(R), R[-1]-R[-1-R[-1]]] else R:= [op(R), q] fi
od:
R; # Robert Israel, Mar 17 2024
MATHEMATICA
s={0, 0}; Do[s1 = If[(c = Count[s[[1;; -2]], s[[-1]]]) == 0, s[[-1]] - s[[-1 - s[[-1]]]], c]; AppendTo[s, s1], {100}]; s (* Amiram Eldar, Aug 13 2019 *)
PROG
(Python)
sa, n = [0], 0
print(n, sa[n])
while n < 50:
i, j = 0, 0
while i < n:
if sa[i] == sa[n]:
j = j+1
i = i+1
if j == 0:
a = sa[n] - sa[n-sa[n]]
else:
a = j
n = n+1
print(n, a)
sa = sa+[a] # A.H.M. Smeets, Aug 09 2019
CROSSREFS
KEYWORD
nonn,look
AUTHOR
Marc Morgenegg, Aug 09 2019
STATUS
approved