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.

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

This page as a plain text file.
%I A360745 #39 Dec 19 2024 11:46:19
%S A360745 1,1,2,3,3,4,4,4,7,7,7,8,9,9,9,9,9,9,12,12,13,13,13,13,13,14,14,17,17,
%T A360745 17,17,17,24,24,24,25,25,26,27,27,28,29,29,29,29,29,29,29,29,30,30,30,
%U A360745 30,30,30,30,30,30,30,33,33,33,34,34,37,37,37,38,38,48,48,48,48,48,49,50,51,52,53,53,53
%N A360745 a(n) is the maximum number of locations 1..n-1 which can be reached starting from a(1)=1, where jumps from location i to i +- a(i) are permitted (within 1..n-1). See example.
%C A360745 a(n) is also the smallest number of terms you can reach from any starting term in the sequence so far. This is true because every term leads back to a(1)=1.
%C A360745 Note that each location can visit up to two terms (doesn't have to be a path), although in this case the example sections shows a path.
%C A360745 a(21)=13 is the earliest term whose solution cannot be represented by a single path in which each index is visited once (found by Kevin Ryde).
%H A360745 Kevin Ryde, <a href="/A360745/b360745.txt">Table of n, a(n) for n = 1..10000</a>
%H A360745 Kevin Ryde, <a href="/A360745/a360745.gp.txt">PARI/GP Code</a>
%H A360745 Neal Gersh Tolunsky, <a href="/A360745/a360745.jpg">Graph of run lengths of a(n) for n = 1..50004</a>
%e A360745 a(13)=9 because we can reach 9 terms starting from a(1) as follows:
%e A360745 1, 1, 2, 3, 3, 4, 4, 4, 7, 7, 7, 8
%e A360745 1->1->2---->3------->4---------->8
%e A360745 1, 1, 2, 3, 3, 4, 4, 4, 7, 7, 7, 8
%e A360745          3<----------------------8
%e A360745 1, 1, 2, 3, 3, 4, 4, 4, 7, 7, 7, 8
%e A360745          3------->4---------->7
%e A360745 This is a total of 9 terms:
%e A360745 1, 1, 2, 3, 3, 4, 4, 4, 7, 7, 7, 8
%e A360745 1  1  2  3  3     4  4        7  8
%o A360745 (Python)
%o A360745 def A(lastn,mode=0):
%o A360745   a,n,t=[1],0,1
%o A360745   while n<lastn:
%o A360745     d,g,r,rr=[[0]],0,0,[0]
%o A360745     while len(d)>0:
%o A360745       if not d[-1][-1] in rr:rr.append(d[-1][-1])
%o A360745       if d[-1][-1]-a[d[-1][-1]]>=0:
%o A360745         if d[-1].count(d[-1][-1]-a[d[-1][-1]])<t:g=1
%o A360745       if d[-1][-1]+a[d[-1][-1]]<=n:
%o A360745         if d[-1].count(d[-1][-1]+a[d[-1][-1]])<t:
%o A360745           if g>0: d.append(d[-1][:])
%o A360745           d[-1].append(d[-1][-1]+a[d[-1][-1]])
%o A360745           r=1
%o A360745       if g>0:
%o A360745         if r>0: d[-2].append(d[-2][-1]-a[d[-2][-1]])
%o A360745         else: d[-1].append(d[-1][-1]-a[d[-1][-1]])
%o A360745         r=1
%o A360745       if r==0:d.pop()
%o A360745       r,g=0,0
%o A360745     a.append(len(rr))
%o A360745     n+=1
%o A360745     print(n+1,a[n])
%o A360745     if mode>0: print(a)
%o A360745   return a  # _S. Brunner_, Feb 19 2023
%o A360745 (PARI) \\ See links.
%Y A360745 Cf. A360744, A360746, A361383, A360593, A359005, A358838, A359008.
%K A360745 nonn
%O A360745 1,3
%A A360745 _Neal Gersh Tolunsky_, Feb 18 2023