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.

A360746 a(n) is the maximum number of locations 1..n-1 which can be reached starting from a(n-1), where jumps from location i to i +- a(i) are permitted (within 1..n-1); a(1)=1. See example.

This page as a plain text file.
%I A360746 #19 Mar 05 2023 11:37:36
%S A360746 1,1,2,3,4,4,5,5,5,7,8,8,8,9,9,12,10,10,12,10,12,13,13,13,16,14,14,16,
%T A360746 17,17,17,18,18,24,25,25,25,26,27,27,27,27,28,28,30,28,33,28,29,30,30,
%U A360746 30,33,31,31,31,32,32,33,33,31,31,32,33,33,35,33,37
%N A360746 a(n) is the maximum number of locations 1..n-1 which can be reached starting from a(n-1), where jumps from location i to i +- a(i) are permitted (within 1..n-1); a(1)=1. See example.
%H A360746 Rémy Sigrist, <a href="/A360746/b360746.txt">Table of n, a(n) for n = 1..10000</a>
%H A360746 Rémy Sigrist, <a href="/A360746/a360746.gp.txt">PARI program</a>
%e A360746 a(7)=5 because we reach 5 terms starting from the most recent term a(6) (each line shows the next unvisited term(s) we can reach from the term(s) in the previous iteration):
%e A360746 1, 1, 2, 3, 4, 4
%e A360746    1<----------4
%e A360746 1, 1, 2, 3, 4, 4
%e A360746 1<-1->2
%e A360746 1, 1, 2, 3, 4, 4
%e A360746       2---->4
%e A360746 From the last iteration we can visit no new terms. We reached 5 terms, so a(7)=5:
%e A360746 1, 1, 2, 3, 4, 4
%e A360746 1  1  2     4  4
%o A360746 (Python)
%o A360746 def A(lastn,mode=0):
%o A360746   a,n,t=[1],0,1
%o A360746   while n<lastn:
%o A360746     d, g, r, rr=[[n]], 0, 0, [n]
%o A360746     while len(d)>0:
%o A360746       if not d[-1][-1] in rr:rr.append(d[-1][-1])
%o A360746       if d[-1][-1]-a[d[-1][-1]]>=0:
%o A360746         if d[-1].count(d[-1][-1]-a[d[-1][-1]])<t:g=1
%o A360746       if d[-1][-1]+a[d[-1][-1]]<=n:
%o A360746         if d[-1].count(d[-1][-1]+a[d[-1][-1]])<t:
%o A360746           if g>0: d.append(d[-1][:])
%o A360746           d[-1].append(d[-1][-1]+a[d[-1][-1]])
%o A360746           r=1
%o A360746       if g>0:
%o A360746         if r>0: d[-2].append(d[-2][-1]-a[d[-2][-1]])
%o A360746         else: d[-1].append(d[-1][-1]-a[d[-1][-1]])
%o A360746         r=1
%o A360746       if r==0:d.pop()
%o A360746       r,g=0,0
%o A360746     a.append(len(rr))
%o A360746     n+=1
%o A360746     print(n+1,a[n])
%o A360746     if mode>0: print(a)
%o A360746   return a  # _S. Brunner_, Feb 26 2023
%o A360746 (PARI) See Links section.
%Y A360746 Cf. A360744, A360745, A360593, A360594, A360595, A359005, A358838, A359008.
%K A360746 nonn
%O A360746 1,3
%A A360746 _Neal Gersh Tolunsky_, Feb 18 2023