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

 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 59th year, we have over 358,000 sequences, and we’ve crossed 10,300 citations (which often say “discovered thanks to the OEIS”). Other ways to Give
 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. MAPLE P:=proc(q) local a, k, m, n: a:=[0, 1]: for n from 2 to q do if numboccur(subsop([n]=NULL, a), a[n])=0 then a:=[op(a), abs(a[n]-a[n-1])]: else for m from n-1 by -1 to 1 do if a[m]=a[n] then break: fi: od: a:=[op(a), a[n]+n-m]: fi: od: op(a); end: P(73); # Paolo P. Lava, Jul 05 2019 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: A176431 A348112 A045747 * A029138 A161051 A161255 Adjacent sequences: A308981 A308982 A308983 * A308985 A308986 A308987 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.

Last modified December 4 09:27 EST 2022. Contains 358556 sequences. (Running on oeis4.)