

A324676


Starting at n, a(n) is the maximal negative position from which a spot must be revisited on the next move, or zero if no such positions exist, according to the following rules. On the kth step (k=1,2,3,...) move a distance of k in the direction of zero. If the number landed on has been landed on before, move a distance of k away.


0



0, 0, 0, 0, 0, 0, 0, 50, 0, 0, 0, 0, 15, 14, 0, 0, 0, 145, 0, 0, 6, 0, 0, 0, 0, 34, 0, 0, 0, 62, 2, 1, 59, 58, 57, 0, 0, 5, 1, 3, 2, 1, 0, 0, 26, 0, 21, 23, 22, 21, 20, 19, 18, 0, 0, 0, 44, 43, 42, 1, 40, 39, 38, 37, 56, 0, 0
(list;
graph;
refs;
listen;
history;
text;
internal format)



OFFSET

0,8


LINKS

Table of n, a(n) for n=0..66.


EXAMPLE

For n=41, the points visited are 41, 40, 38, 35, 31, 26, 20, 13, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 10, 9, 11, 10, 12, 11, 35, 60, 34, 61, 33, 62, 32, 1, 33, 0. The only position from which we are forced to revisit a spot is 1 which forces a return to 33. As this is the only position and it is negative, it is the maximum negative position and thus a(41)=1.


PROG

(Python)
#Sequences A324660A324692 generated by manipulating this trip function
#spots  positions in order with possible repetition
#flee  positions from which we move away from zero with possible repetition
#stuck  positions from which we move to a spot already visited with possible repetition
def trip(n):
stucklist = list()
spotsvisited = [n]
leavingspots = list()
turn = 0
forbidden = {n}
while n != 0:
turn += 1
sign = n // abs(n)
st = sign * turn
if n  st not in forbidden:
n = n  st
else:
leavingspots.append(n)
if n + st in forbidden:
stucklist.append(n)
n = n + st
spotsvisited.append(n)
forbidden.add(n)
return {'stuck':stucklist, 'spots':spotsvisited,
'turns':turn, 'flee':leavingspots}
def maxorzero(x):
if x:
return max(x)
return 0
#Actual sequence
def a(n):
d=trip(n)
return maxorzero([i for i in d['stuck'] if i<0])


CROSSREFS

Cf. A228474, A324660A324692.
Sequence in context: A013843 A303146 A023936 * A015066 A022078 A174914
Adjacent sequences: A324673 A324674 A324675 * A324677 A324678 A324679


KEYWORD

sign


AUTHOR

David Nacin, Mar 10 2019


STATUS

approved



