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.

Original entry on oeis.org

0, 1, 6, 3, 68, 72, 6, 13205, 31, 36, 10, 104, 836, 836, 43, 15, 570, 9518374, 57, 60, 1548481, 21, 203, 80, 87, 15466141, 71, 71, 28, 2436, 118129102, 6815959, 6815959, 6815959, 6815959, 86, 36, 560, 2261901, 2261901, 1091, 103, 103, 103, 6831, 45, 758, 499
Offset: 0

Views

Author

David Nacin, Mar 10 2019

Keywords

Examples

			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.
		

Crossrefs

Programs

  • 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(d['spots'])-min(d['spots'])