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.

A324661 Starting at n, a(n) is the total number of moves made to the left 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.

This page as a plain text file.
%I A324661 #11 Mar 11 2019 20:32:02
%S A324661 0,1,3,2,14,15,3,864,8,9,4,15,64,65,10,5,62,390904,13,14,66452,6,29,
%T A324661 18,19,610401,15,16,7,218,4434563,266008,266007,266008,266009,17,8,51,
%U A324661 106681,106680,128,21,20,21,505,9,77,60,61,46,47,110,35,22,23,10,327
%N A324661 Starting at n, a(n) is the total number of moves made to the left 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.
%e A324661 For n=2, the points visited are 2,1,-1,-4,0 with the moves from 2 to 1, 1 to -1, and -1 to -4 being the only ones to the left, hence a(2)=3.
%o A324661 (Python)
%o A324661 #Sequences A324660-A324692 generated by manipulating this trip function
%o A324661 #spots - positions in order with possible repetition
%o A324661 #flee - positions from which we move away from zero with possible repetition
%o A324661 #stuck - positions from which we move to a spot already visited with possible repetition
%o A324661 def trip(n):
%o A324661     stucklist = list()
%o A324661     spotsvisited = [n]
%o A324661     leavingspots = list()
%o A324661     turn = 0
%o A324661     forbidden = {n}
%o A324661     while n != 0:
%o A324661         turn += 1
%o A324661         sign = n // abs(n)
%o A324661         st = sign * turn
%o A324661         if n - st not in forbidden:
%o A324661             n = n - st
%o A324661         else:
%o A324661             leavingspots.append(n)
%o A324661             if n + st in forbidden:
%o A324661                 stucklist.append(n)
%o A324661             n = n + st
%o A324661         spotsvisited.append(n)
%o A324661         forbidden.add(n)
%o A324661     return {'stuck':stucklist, 'spots':spotsvisited,
%o A324661                 'turns':turn, 'flee':leavingspots}
%o A324661 #Actual sequence
%o A324661 def a(n):
%o A324661     d = trip(n)
%o A324661     return sum(1 for i in range(d['turns']) if d['spots'][i+1] < d['spots'][i])
%Y A324661 Cf. A228474, A324660-A324692. Equals (A228474-A324660).
%K A324661 nonn
%O A324661 0,3
%A A324661 _David Nacin_, Mar 10 2019