This site is supported by donations to The OEIS Foundation. 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: A175003 A176431 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 | Recent
The OEIS Community | Maintained by The OEIS Foundation Inc.

Last modified November 18 02:02 EST 2019. Contains 329242 sequences. (Running on oeis4.)