cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

A324673 Starting at n, a(n) is the length of the smallest interval containing all points 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.

This page as a plain text file.
%I A324673 #18 Jul 23 2025 16:00:52
%S A324673 0,1,6,3,68,72,6,13205,31,36,10,104,836,836,43,15,570,9518374,57,60,
%T A324673 1548481,21,203,80,87,15466141,71,71,28,2436,118129102,6815959,
%U A324673 6815959,6815959,6815959,86,36,560,2261901,2261901,1091,103,103,103,6831,45,758,499
%N A324673 Starting at n, a(n) is the length of the smallest interval containing all points 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.
%e A324673 For n=2, the points visited are 2,1,-1,-4,0.  The smallest interval containing these is [-4,2] which has length 6, thus a(2) = 6.
%o A324673 (Python)
%o A324673 #Sequences A324660-A324692 generated by manipulating this trip function
%o A324673 #spots - positions in order with possible repetition
%o A324673 #flee - positions from which we move away from zero with possible repetition
%o A324673 #stuck - positions from which we move to a spot already visited with possible repetition
%o A324673 def trip(n):
%o A324673     stucklist = list()
%o A324673     spotsvisited = [n]
%o A324673     leavingspots = list()
%o A324673     turn = 0
%o A324673     forbidden = {n}
%o A324673     while n != 0:
%o A324673         turn += 1
%o A324673         sign = n // abs(n)
%o A324673         st = sign * turn
%o A324673         if n - st not in forbidden:
%o A324673             n = n - st
%o A324673         else:
%o A324673             leavingspots.append(n)
%o A324673             if n + st in forbidden:
%o A324673                 stucklist.append(n)
%o A324673             n = n + st
%o A324673         spotsvisited.append(n)
%o A324673         forbidden.add(n)
%o A324673     return {'stuck':stucklist, 'spots':spotsvisited,
%o A324673                 'turns':turn, 'flee':leavingspots}
%o A324673 #Actual sequence
%o A324673 def a(n):
%o A324673     d=trip(n)
%o A324673     return max(d['spots'])-min(d['spots'])
%Y A324673 Cf. A228474, A324660-A324692. Equals A248953 - A248952.
%K A324673 nonn
%O A324673 0,3
%A A324673 _David Nacin_, Mar 10 2019