login
A324671
Starting at n, a(n) is the distance from zero of the farthest point visited according to the following rules. On the k-th 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 from zero instead.
1
0, 1, 4, 3, 47, 46, 6, 6843, 23, 22, 10, 72, 471, 470, 29, 15, 352, 4843985, 39, 38, 891114, 21, 102, 57, 56, 7856204, 45, 44, 28, 1700, 61960674, 3702823, 3702824, 3702825, 3702826, 51, 36, 370, 1213998, 1213997, 596, 62, 61, 60, 3855, 45, 417, 260, 261, 237
OFFSET
0,3
EXAMPLE
For n=2, the points visited are 2,1,-1,-4,0. Of those the one farthest from zero is -4 with a distance of 4, hence a(2) = 4.
PROG
(Python)
#Sequences A324660-A324692 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}
#Actual sequence
def a(n):
d = trip(n)
return max(abs(i) for i in d['spots'])
CROSSREFS
Cf. A228474, A324660-A324692. Equals max(A248953, -A248952).
Sequence in context: A248247 A016504 A362275 * A249226 A328193 A273878
KEYWORD
nonn
AUTHOR
David Nacin, Mar 10 2019
STATUS
approved