login
A359728
a(1) = 1; a(n) is the smallest positive number not among the first k terms where k is the number of times a(n-1) has occurred.
1
1, 2, 2, 3, 2, 3, 3, 3, 4, 2, 4, 3, 4, 3, 4, 4, 4, 4, 4, 4, 5, 2, 4, 5, 3, 4, 5, 3, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 2, 4, 5, 6, 3, 5, 6, 3, 5, 6, 4, 5, 6, 4, 5, 6, 4, 6, 4, 6, 4, 6, 5, 6, 5, 6, 5, 6, 5, 6, 5, 6, 5, 6
OFFSET
1,2
COMMENTS
A new number is always followed by a 2.
LINKS
EXAMPLE
a(4) is 3 because the previous term (2) appears two times; we therefore look at the first 2 terms (1,2). 3 is the smallest number not among them, so a(4) is 3.
a(21) is 5: We see that a(20)=4 appears 9 times; the smallest number not among the first 9 terms (1,2,2,3,2,3,3,3,4) is 5.
MATHEMATICA
K = {1}; While[Length@K < 87, T = Take[K, Count[K, Last@K]]; i = 1; While[MemberQ[T, i], i++]; AppendTo[K, i]]; Print[K] (* Samuel Harkness, Mar 12 2023 *)
PROG
(PARI) lista(nn) = my(va=vector(nn)); va[1] = 1; for (n=2, nn, my(k=#select(x->(x==va[n-1]), va)); my(vb=Vec(va, k), m); for(j=1, vecmax(vb)+1, if (! #select(x->(x==j), vb), m=j; break)); va[n] = m; ); va; \\ Michel Marcus, Jan 13 2023
CROSSREFS
Cf. A358921.
Sequence in context: A358550 A126071 A338292 * A217865 A185166 A276555
KEYWORD
nonn
AUTHOR
Neal Gersh Tolunsky, Jan 11 2023
STATUS
approved