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.

A324692 a(n) = partial sums of A324672.

This page as a plain text file.
%I A324692 #5 Mar 11 2019 20:46:56
%S A324692 0,0,1,0,1,0,-1,0,1,0,-1,0,1,0,-1,-2,-1,0,-1,-2,-3,-2,-1,0,-1,-2,-1,
%T A324692 -2,-3,-2,-1,0,1,2,3,4,3,4,5,4,3,4,3,2,1,0,1,0,1,2,1,0,1,0,-1,-2,-1,0,
%U A324692 1,2,1,0,-1,-2,-3,-4,-5,-4,-5,-6,-7,-6,-5,-4,-3,-2
%N A324692 a(n) = partial sums of A324672.
%H A324692 David Nacin, <a href="/A324692/a324692.png">A324692</a>
%o A324692 (Python)
%o A324692 import functools
%o A324692 #Sequences A324660-A324691 generated by manipulating this trip function
%o A324692 #spots - positions in order with possible repetition
%o A324692 #flee - positions from which we move away from zero with possible repetition
%o A324692 #stuck - positions from which we move to a spot already visited with possible repetition
%o A324692 def trip(n):
%o A324692     stucklist = list()
%o A324692     spotsvisited = [n]
%o A324692     leavingspots = list()
%o A324692     turn = 0
%o A324692     forbidden = {n}
%o A324692     while n != 0:
%o A324692         turn += 1
%o A324692         sign = n // abs(n)
%o A324692         st = sign * turn
%o A324692         if n - st not in forbidden:
%o A324692             n = n - st
%o A324692         else:
%o A324692             leavingspots.append(n)
%o A324692             if n + st in forbidden:
%o A324692                 stucklist.append(n)
%o A324692             n = n + st
%o A324692         spotsvisited.append(n)
%o A324692         forbidden.add(n)
%o A324692     return {'stuck':stucklist, 'spots':spotsvisited,
%o A324692                 'turns':turn, 'flee':leavingspots}
%o A324692 def sgn(x):
%o A324692     if x:
%o A324692         return x//abs(x)
%o A324692     return 0
%o A324692 @functools.lru_cache(maxsize=None)
%o A324692 def A324672(n):
%o A324692     d = trip(n)
%o A324692     mx=max([i for i in d['spots']])
%o A324692     mn=min([i for i in d['spots']])
%o A324692     return sgn(mx+mn)
%o A324692 #Actual sequence
%o A324692 def a(n):
%o A324692     return sum(A324672(i) for i in range(n))
%Y A324692 Cf. A228474, A324660-A324692.
%K A324692 sign
%O A324692 0,16
%A A324692 _David Nacin_, Mar 11 2019