[go: up one dir, main page]

login

Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).

A309596
If a(n) is not a term of a(0..n-1), then a(n+1) = a(n) - a(n - a(n)); otherwise a(n+1) is the number of terms equal to a(n) in a(0..n-1). Start with a(0)=0, a(1)=0.
1
0, 0, 1, 1, 1, 2, 1, 3, 2, 1, 4, 3, 1, 5, 3, 2, 2, 3, 3, 4, 1, 6, 4, 2, 4, 3, 5, 1, 7, 1, 8, 4, 4, 5, 2, 5, 3, 6, 1, 9, 1, 10, 6, 2, 6, 3, 7, 1, 11, 5, 4, 6, 4, 7, 2, 7, 3, 8, 1, 12, 11, 1, 13, 8, 2, 8, 3, 9, 1, 14, 7, 4
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
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
Sequence in context: A278104 A141672 A141671 * A335442 A226247 A233742
KEYWORD
nonn,look
AUTHOR
Marc Morgenegg, Aug 09 2019
STATUS
approved