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!)
A308984 If a(n) is not a term of a(0)..a(n-1), then a(n+1) = |a(n) - a(n-1)|, otherwise a(n+1) = a(n) + n - m, where a(m) = a(n), m < n, and m is maximal. a(0)=0, a(1)=1. 1
0, 1, 1, 2, 1, 3, 2, 5, 3, 6, 3, 5, 9, 4, 5, 8, 3, 9, 14, 5, 10, 5, 7, 2, 19, 17, 2, 5, 11, 6, 26, 20, 6, 9, 25, 16, 9, 12, 3, 25, 30, 5, 19, 37, 18, 19, 22, 3, 12, 23, 11, 33, 22, 28, 6, 28, 30, 46, 16, 39, 23, 34, 11, 23, 26, 60, 34, 39, 47, 8, 62, 54, 8, 11 (list; graph; refs; listen; history; text; internal format)
OFFSET
0,4
COMMENTS
In other words, if the last term has not appeared previously, take the absolute difference between the previous term and itself to obtain the next one; otherwise, add to the last term the difference between its index and that of the last identical term to obtain the next one.
The sequence is infinite, because loops are impossible.
LINKS
Sean A. Irvine, Java program (github)
EXAMPLE
a(0)=0 (given).
a(1)=1 (given).
a(2)=1: a(1) is not a term of a(0..0), therefore a(2) = |a(1) - a(0)| = 1 - 0 = 1.
a(3)=2: a(2)=a(1), therefore a(3) = a(2) + 2 - 1 = 1 + 2 - 1 = 2.
a(4)=1: a(3) is not a term of a(0..2), therefore a(4) = |a(3) - a(2)| = 2 - 1 = 1.
a(5)=3: a(4)=a(2), therefore a(5) = a(4) + 4 - 2 = 1 + 4 - 2 = 3.
a(6)=2: a(5) is not a term of a(0..4), therefore a(6) = |a(5) - a(4)| = 3 - 1 = 2.
MATHEMATICA
Nest[Function[{a, n}, Append[a, If[FreeQ[Most@ a, Last@ a], Abs[Subtract @@ a[[-2 ;; -1]] ], Last[a] + n - Position[Most@ a, _?(# == Last@ a &)][[-1, 1]] ]]] @@ {#, Length@ #} &, {0, 1}, 72] (* Michael De Vlieger, Jul 08 2019 *)
CROSSREFS
Sequence in context: A363083 A348112 A045747 * A029138 A161051 A161255
KEYWORD
nonn
AUTHOR
Marc Morgenegg, Jul 04 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 April 24 22:17 EDT 2024. Contains 371964 sequences. (Running on oeis4.)