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”).

A239281
a(1) = 0; for n>1, a(n) is one more than the value of the sequence at index the number of times a(n-1) has previously appeared in the sequence.
1
0, 1, 1, 2, 1, 2, 2, 2, 3, 1, 3, 2, 2, 3, 2, 3, 3, 2, 3, 3, 3, 3, 4, 1, 2, 4, 2, 2, 4, 2, 3, 2, 3, 4, 3, 3, 3, 4, 2, 4, 3, 3, 4, 3, 4, 3, 3, 4, 4, 2, 3, 4, 4, 3, 4, 3, 4, 4, 3, 5, 1, 3, 2, 4, 4, 4, 3, 3, 5, 2, 4, 4, 4, 4, 4, 5, 2, 3, 3, 3, 5, 3, 3, 4, 2, 4, 3, 3, 4, 5, 2, 4, 3, 5, 3, 4, 3, 4, 5, 3
OFFSET
1,4
COMMENTS
The same sequence is obtained by looking at the values following each occurrence of each positive integer; and that sequence is this sequence plus one.
Every positive integer occurs infinitely many times. - Ivan Neretin, May 02 2016
LINKS
MAPLE
a:= proc() local a, c, t;
c:= proc() 0 end; c(0):=1;
a:= proc(n) option remember;
if n=1 then 0
else t:= 1+a(c(a(n-1)));
c(t):= c(t)+1; t
fi
end
end():
seq(a(n), n=1..120); # Alois P. Heinz, Mar 15 2014
MATHEMATICA
a[_] = 0; nmax = 120;
Do[a[i+1] = 1 + a[Sum[Boole[a[j] == a[i]], {j, 1, i}]], {i, 1, nmax-1}];
Table[a[n], {n, 1, nmax}] (* Jean-François Alcover, Apr 28 2022 *)
PROG
(PARI) al(n)={local(r=vector(n), i, j);
for(i=1, n-1, r[i+1]=1+r[sum(j=1, i, if(r[j]==r[i], 1, 0))]);
r}
(Python)
from collections import Counter
from itertools import count, islice
def agen(): # generator of terms
an, a, c = 0, dict(), Counter()
for n in count(1):
yield an
a[n] = an
c[an] += 1
an = a[c[an]] + 1
print(list(islice(agen(), 100))) # Michael S. Branicky, Jul 12 2024
CROSSREFS
Sequence in context: A065531 A366574 A256558 * A024936 A144590 A057368
KEYWORD
nonn
AUTHOR
STATUS
approved