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

%I #36 Feb 28 2024 10:46:35

%S 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,

%T 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,

%U 30,46,16,39,23,34,11,23,26,60,34,39,47,8,62,54,8,11

%N 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.

%C 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.

%C The sequence is infinite, because loops are impossible.

%H Sean A. Irvine, <a href="https://github.com/archmageirvine/joeis/blob/master/src/irvine/oeis/a308/A308984.java">Java program</a> (github)

%e a(0)=0 (given).

%e a(1)=1 (given).

%e a(2)=1: a(1) is not a term of a(0..0), therefore a(2) = |a(1) - a(0)| = 1 - 0 = 1.

%e a(3)=2: a(2)=a(1), therefore a(3) = a(2) + 2 - 1 = 1 + 2 - 1 = 2.

%e a(4)=1: a(3) is not a term of a(0..2), therefore a(4) = |a(3) - a(2)| = 2 - 1 = 1.

%e a(5)=3: a(4)=a(2), therefore a(5) = a(4) + 4 - 2 = 1 + 4 - 2 = 3.

%e a(6)=2: a(5) is not a term of a(0..4), therefore a(6) = |a(5) - a(4)| = 3 - 1 = 2.

%t 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 *)

%K nonn

%O 0,4

%A _Marc Morgenegg_, Jul 04 2019

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 16 04:17 EDT 2024. Contains 371696 sequences. (Running on oeis4.)