login
A358921
a(1) = 1; a(n) is the smallest positive number not among the terms a(n-c .. n-1) where c = the number of times a(n-1) has occurred.
6
1, 2, 1, 3, 1, 2, 3, 1, 4, 1, 5, 1, 2, 3, 4, 1, 6, 1, 7, 1, 5, 2, 3, 4, 1, 8, 1, 9, 1, 6, 2, 3, 4, 1, 5, 2, 6, 1, 7, 2, 3, 4, 5, 1, 8, 2, 6, 3, 7, 1, 9, 2, 4, 5, 3, 6, 1, 10, 1, 11, 1, 12, 1, 13, 1, 14, 1, 8, 2, 3, 4, 5, 6, 1, 7, 2, 9, 1, 15, 1, 16, 1, 17, 1
OFFSET
1,2
COMMENTS
A new number other than 1 is always followed by a 1, so a(n) < n/2 for n > 4.
EXAMPLE
For a(6), a(5) = 1 has occurred 3 times, so the smallest positive integer not in {a(5), a(4), a(3)} = {1, 3, 1} is 2, thus a(6) = 2.
Next, for a(7), a(6) = 2 has occurred 2 times, so the smallest positive integer not in {a(6), a(5)} = {2, 1} is 3, thus a(7) = 3.
Then, for a(8), a(7) = 3 has occurred 2 times, so the smallest positive integer not in {a(7), a(6)} = {3, 2} is 1, thus a(8) = 1.
Now, for a(9), a(8) = 1 has occurred 4 times, so the smallest positive integer not in {a(8), a(7), a(6), a(5)} = {1, 3, 2, 1} is 4, thus a(9) = 4.
The first terms, alongside the number of times they have occurred o(n), are:
n a(n) o(n)
- ---- ----
1 1 1
2 2 1
3 1 2
4 3 1
5 1 3
6 2 2
7 3 2
8 1 4
9 4 1
10 1 5
MATHEMATICA
V = {1} While[Length[V] < 84, b = 1; While[MemberQ[Take[V, -Count[V, Last[V]]], b], b++ ]; AppendTo[V, b]]; Print[V]
PROG
(PARI) { a = o = vector(84); v = 1; for (n=1, #a, print1 (a[n]=v", "); v=setminus([1..n+1], Set(a[n-o[a[n]]+++1..n]))[1]) } \\ Rémy Sigrist, Jan 09 2023
CROSSREFS
KEYWORD
nonn,hear,look
AUTHOR
Samuel Harkness, Dec 06 2022
STATUS
approved