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!)
A328294 Set a(1)=1 and a(2)=2. For n > 2, if a(n) had already appeared in the sequence, then a(n+1) = number of steps since its most recent appearance, as in Van Eck's sequence A181391. If a(n) had not appeared before, search instead for a(n)-1, then a(n)-2, etc., until you find a number that has appeared before. 3
1, 2, 1, 2, 2, 1, 3, 2, 3, 2, 2, 1, 6, 4, 5, 1, 4, 3, 9, 6, 7, 1, 6, 3, 6, 2, 15, 8, 7, 8, 2, 5, 17, 6, 9, 16, 9, 2, 7, 10, 3, 17, 9, 6, 10, 5, 14, 2, 10, 4, 33, 9, 9, 1, 32, 13, 7, 18, 16, 23, 2, 13, 6, 19, 6, 2, 5, 21, 4, 19, 6, 6, 1, 19, 4, 6, 4, 2, 12, 30 (list; graph; refs; listen; history; text; internal format)
OFFSET
1,2
COMMENTS
In other words, let a(1)=1, a(2)=2, and for any n >= 2, let v be the greatest value <= a(n) among the first n-1 terms; a(n+1) is the least d > 0 such that a(n-d) = v.
LINKS
EXAMPLE
We start with a(1) = 1 and a(2) = 2. 2 has not appeared before, so we search for the greatest valid integer less than 2, which in this case is 1. 1 last occurred at a(1), which is 1 term before, so a(3) = 1.
1 occurred 2 terms before, so a(4) = 2.
2 appeared at term a(2), which is 2 terms before, so a(5) = 2.
2 appeared most recently at term a(5), which is 1 term earlier, so a(6) = 1.
And so on.
PROG
(PARI) seq(n)={my(a=vector(n)); a[1]=1; a[2]=2; for(n=2, n-1, my(m=1); for(i=2, n-1, if(a[i] <= a[n] && a[i] >= a[m], m=i)); a[n+1]=n-m); a} \\ Andrew Howroyd, Oct 25 2019
CROSSREFS
Sequence in context: A109699 A301563 A330896 * A029283 A264404 A116482
KEYWORD
nonn
AUTHOR
Robin Powell, Oct 11 2019
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 March 28 18:04 EDT 2024. Contains 371254 sequences. (Running on oeis4.)