OFFSET
1,3
COMMENTS
The sequence refers to itself. If k = a(n-1) is a novel term, then a(n) equals the term whose index is k; otherwise a(n) is the number of times k has appeared in a(1)..a(n-1).
All positive integers appear in the sequence.
For any n, there exist numbers m > n such that a(m) = a(n), and there exist numbers m > n such that a(m) > a(n).
The graph of the largest number a(n) in the interval n = 1..j grows approximately as j^0.66.
LINKS
Thomas Scheuerle, Scatter plot of a(1 to 2000). Yellow: a(n) = a(a(n-1)), blue: a(n) indicates how often the value of a(n-1) appeared previously.
EXAMPLE
a(1) = 1 by definition.
For n = 2, a(1) = 1 has appeared only 1 time, so a(2) = a(a(1)) = a(1) = 1.
For n = 3, a(2) = 1 has appeared 2 times, so a(3) = 2.
For n = 4, a(3) = 2 has appeared only 1 time, so a(4) = a(a(3)) = a(2) = 1.
For n = 5, a(4) = 1 has appeared 3 times, so a(5) = 3.
For n = 6, a(5) = 3 has appeared only 1 time, so a(6) = a(a(5)) = a(3) = 2.
In the table below, m is the number of times that the value a(n-1) has appeared among the terms a(1)..a(n-1).
.
n a(n-1) m a(n) comments
-- ------ - ---- -----------------------------------
1 - - 1 (by definition)
2 1 1 1 m = 1, so a(2) = a(a(1)) = a(1) = 1
3 1 2 2 m > 1, so a(3) = m
4 2 1 1 m = 1, so a(4) = a(a(3)) = a(2) = 1
5 1 3 3 m > 1, so a(5) = m
6 3 1 2 m = 1, so a(6) = a(a(5)) = a(3) = 2
7 2 2 2 m > 1, so a(7) = m
8 2 3 3 m > 1, so a(8) = m
9 3 2 2 m > 1, so a(9) = m
10 2 4 4 m > 1, so a(10) = m
PROG
(Python)
def generate_sequence(n):
sequence = [1]
for i in range(1, n):
last_number = sequence[-1]
if sequence.count(last_number) == 1:
next_number = sequence[last_number - 1]
else:
next_number = sequence.count(last_number)
sequence.append(next_number)
return sequence
n = 30
print(generate_sequence(n))
(PARI) lista(nn) = my(va= vector(nn)); va[1] = 1; for (n=2, nn, my(nb = #select(x->(x==va[n-1]), va)); if (nb<=1, va[n] = va[va[n-1]], va[n] = nb); ); va; \\ Michel Marcus, Jul 04 2024
CROSSREFS
KEYWORD
nonn
AUTHOR
Mario Cortés, Jul 03 2024
STATUS
approved