The OEIS mourns the passing of Jim Simons and is grateful to the Simons Foundation for its support of research in many branches of science, including the OEIS.
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!)
A308619 Negative van Eck's sequence: For n >= 1, if there exists an m < n such that a(m) = a(n), take the largest such m and set a(n+1) = n-m, otherwise a(n+1) = -a(n). Start with a(1)=0. 1

%I #26 Jul 27 2019 16:45:06

%S 0,0,1,-1,1,2,-2,2,2,1,5,-5,5,2,5,2,2,1,8,-8,8,2,5,8,3,-3,3,2,6,-6,6,

%T 2,4,-4,4,2,4,2,2,1,22,-22,22,2,5,22,3,20,-20,20,2,7,-7,7,2,4,19,-19,

%U 19,2,5,16,-16,16,2,5,5,1,28,-28,28,2,7,19,15,-15,15,2,6,48,-48,48,2,5,17,-17,17,2,5,5,1,23,-23,23,2,7,23,3,51,-51

%N Negative van Eck's sequence: For n >= 1, if there exists an m < n such that a(m) = a(n), take the largest such m and set a(n+1) = n-m, otherwise a(n+1) = -a(n). Start with a(1)=0.

%C Similar logic as van Eck's sequence except that if a(n) hasn't appeared before, then a(n+1) = -a(n) instead of being 0.

%F If a(n) < 0, then a(n+1) = -a(n) and a(n+2) = 2. - _Rémy Sigrist_, Jul 14 2019

%e We start with a(1) = 0.

%e 0 has not occurred before, so our rule says that a(2) = -a(1) = 0.

%e Now 0 has occurred before, at a(1), which is 1 term before, so a(3) = 1.

%e 1 has not occurred before, so a(4) = -a(3) = -1.

%e -1 has not occurred before, so a(5) = -a(4) = 1.

%e Now 1 has occurred before, at a(3), which is 2 term before, so a(6) = 2.

%e 2 has not occurred before, so a(6) = -a(5) = -2.

%e And so on...

%o (Python)

%o import numpy as np

%o def A308619(n):

%o NegVanEck = np.array([0])

%o #first value is 0

%o i=NegVanEck[0]

%o while i < n:

%o last = NegVanEck[-1]

%o pos = np.where(NegVanEck == last)

%o if pos[0].size == 1:

%o NegVanEck = np.append(NegVanEck, -last)

%o else:

%o NegVanEck = np.append(NegVanEck, pos[0][-1] - pos[0][-2])

%o i += 1

%o return NegVanEck

%o print(A308619(1000)) #prints first 1000 integers of the sequence

%Y Cf. A181391.

%K sign

%O 1,6

%A _João D. R. Camacho_, Jun 11 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 June 9 14:04 EDT 2024. Contains 373243 sequences. (Running on oeis4.)