|
|
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
|
|
|
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, 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, 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
(list;
graph;
refs;
listen;
history;
text;
internal format)
|
|
|
OFFSET
|
1,6
|
|
COMMENTS
|
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.
|
|
LINKS
|
|
|
FORMULA
|
If a(n) < 0, then a(n+1) = -a(n) and a(n+2) = 2. - Rémy Sigrist, Jul 14 2019
|
|
EXAMPLE
|
We start with a(1) = 0.
0 has not occurred before, so our rule says that a(2) = -a(1) = 0.
Now 0 has occurred before, at a(1), which is 1 term before, so a(3) = 1.
1 has not occurred before, so a(4) = -a(3) = -1.
-1 has not occurred before, so a(5) = -a(4) = 1.
Now 1 has occurred before, at a(3), which is 2 term before, so a(6) = 2.
2 has not occurred before, so a(6) = -a(5) = -2.
And so on...
|
|
PROG
|
(Python)
import numpy as np
NegVanEck = np.array([0])
#first value is 0
i=NegVanEck[0]
while i < n:
last = NegVanEck[-1]
pos = np.where(NegVanEck == last)
if pos[0].size == 1:
NegVanEck = np.append(NegVanEck, -last)
else:
NegVanEck = np.append(NegVanEck, pos[0][-1] - pos[0][-2])
i += 1
return NegVanEck
print(A308619(1000)) #prints first 1000 integers of the sequence
|
|
CROSSREFS
|
|
|
KEYWORD
|
sign
|
|
AUTHOR
|
|
|
STATUS
|
approved
|
|
|
|