login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A320838 a(0) = 0, a(n) is the number of x such that a(x) = a(n-1) and there exists no y such that x < y < n and a(y) > a(n-1). 0
0, 1, 1, 2, 1, 1, 2, 2, 3, 1, 1, 2, 1, 1, 2, 2, 3, 2, 1, 1, 2, 2, 3, 3, 4, 1, 1, 2, 1, 1, 2, 2, 3, 1, 1, 2, 1, 1, 2, 2, 3, 2, 1, 1, 2, 2, 3, 3, 4, 2, 1, 1, 2, 2, 3, 1, 1, 2, 1, 1, 2, 2, 3, 2, 1, 1, 2, 2, 3, 3, 4, 3, 1, 1, 2, 1, 1, 2, 2, 3, 2, 1, 1, 2, 2, 3, 3, 4, 4, 5 (list; graph; refs; listen; history; text; internal format)
OFFSET
0,4
COMMENTS
After the n-th occurrence (with n <= m) of m after a number larger than n comes the segment of the sequence from the first appearance of n to the first appearance of m.
The first appearance of n in this sequence is given by A002104(n).
LINKS
FORMULA
Let s(n) be the first time n appears in the sequence, then s(n) = Sum_{k=0...n-1} (s(n-1)-s(k)+1).
EXAMPLE
Start with a(0) = 0.
No larger number has occurred yet, and the number of 0's since the start of the sequence is 1, so a(1) = 1.
No larger number has occurred yet, and the number of 1's since the start of the sequence is 1, so a(2) = 1.
Still no larger number has occurred, and the number of 1's since the start of the sequence is 2, so a(3) = 2.
No larger number has occurred yet, and the number of 2's since the start of the sequence is 1, so a(4) = 1.
The number of 1's that have occurred since the last appearance of a larger number is 1, so a(5) = 1.
Etc.
MATHEMATICA
a[0] = 0; a[n_] := a[n] = Count[Range[0, n-1], x_ /; a[x] == a[n - 1] && ! AnyTrue[ Range[x+1, n-1], a[#] > a[n-1] &]]; a /@ Range[0, 89] (* Giovanni Resta, Oct 22 2018 *)
PROG
(PARI) lista(nn) = {va = vector(nn); va[1] = 0; for (n=2, nn, nb = 0; forstep (k=n-1, 1, -1, if (va[k] == va[n-1], nb++); if (va[k] > va[n-1], break); ); va[n] = nb; ); va; } \\ Michel Marcus, Oct 22 2018
CROSSREFS
Cf. A002104.
Sequence in context: A153904 A128762 A126307 * A092332 A092334 A269971
KEYWORD
nonn
AUTHOR
Thomas Anton, Oct 21 2018
STATUS
approved

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified April 19 19:02 EDT 2024. Contains 371798 sequences. (Running on oeis4.)