OFFSET
0,3
COMMENTS
Starting at n, a(n) is the maximum reached according to the following rules: Unless 0 has been reached, on the k-th step (k = 1, 2, 3, ...) move a distance of k in the direction of zero. If the result has already occurred before, move a distance of k away from zero instead. See A228474 and A248939. - David Nacin, Mar 15 2019
It is currently unproved that all orbits are finite, and therefore unclear whether all a(n) are well defined. In particular, the orbit of n = 11281 is of unknown length > 32*10^9 steps. - M. F. Hasler, Mar 18 2019
LINKS
M. F. Hasler, Table of n, a(n) for n = 0..5000 (terms up to n = 1000 from Reinhard Zumkeller), Mar 18 2019
Gordon Hamilton, Wrecker Ball Sequences, Video, 2013
EXAMPLE
a(0) = max {0} = 0;
a(1) = max {1,0} = 1;
a(2) = max {2,1,-1,-4,0} = 2;
a(3) = max {3,2,0} = 3;
a(4) = max {4,3,1,-2,2,-3,-9,-16,-8,-17,-7,-18,-6,7,21,6,-10,-27,...} = 21;
a(5) = max {5,4,2,-1,3,-2,-8,-15,-7,-16,-6,-17,-5,8,22,7,-9,-26,...} = 26;
a(6) = max {6,5,3,0} = 6;
a(7) = max {7,6,4,1,-3,2,-4,3,-5,-14,-24,-13,-1,12,-2,13,29,46,...} = 6843;
a(8) = max {8,7,5,2,-2,3,-3,4,-4,-13,-23,-12,0} = 8;
a(9) = max {9,8,6,3,-1,4,-2,5,-3,-12,-22,-11,1,14,0} = 14.
PROG
(Haskell)
a248953 n = a248953_list !! n
-- See A248952 for definition of a248953_list.
(Python)
#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(d['spots'])
# David Nacin, Mar 15 2019
(C++) #include<map>
long A248953(long n) { long c=0, s, m=n; for(std::map<long, bool> seen; n; n += seen[n-(s=n>0?c:-c)] ? s:-s) { if(n>m) m=n; seen[n]=true; ++c; } return m; } // M. F. Hasler, Mar 18 2019
CROSSREFS
KEYWORD
nonn
AUTHOR
Reinhard Zumkeller, Oct 18 2014
EXTENSIONS
Edited by M. F. Hasler, Mar 18 2019
STATUS
approved