OFFSET
0,3
COMMENTS
For clarification:
The terms of the sequence so far are written as a one-dimensional grid, and from every term a(i) you can jump back or forth a(i) terms, without i getting < 0 or > n, as these terms don't exist. Then search for the longest possible chain of jumps you can do starting at a(n) and visiting no term more than once. The number of targets visited by this chain is the next term of the sequence.
A chain of jumps C always starts at n, with C1 = a(n-1). Then the first jump always has to go back C1 terms, so C2 = a(n-1-C1) = a(n-1-a(n-1)), and then it continues with jumping back or forth C2 terms, whichever produces the longest chain of jumps:
C3 = a(n-1-C1-C2) or a(n-1-C1+C2),
C4 = a(n-1-C1{-/+}C2{-/+}C3), etc.
The first numbers which appear to be missing from this sequence are:
3, 13, 15, 17, 20, 25, 27, 32, 33, 36, 43, 44, 48, 50, 51, 62, 63, 69, 70, 71, 75, 77, 78, 80, etc.
LINKS
S. Brunner, Table of n, a(n) for n = 0..217
EXAMPLE
This example shows the longest chain of jumps starting with a(7)=2:
0, 1, 2, 2, 4, 2, 6, 2
1<----2<----2<----2
->2---->4
0<----------
It visited the 7 terms 2,2,2,1,2,4,0. So a(8)=7.
PROG
(Python)
def A(lastn, times=1, mode=0):
a, n=[0], 0
while n<lastn:
d, i, v, o, g, r=[[n]], 0, 1, [], 0, 0
while len(d)>0:
if len(d[-1])>v: v, o=len(d[-1]), d[-1][:]
if d[-1][-1]-a[d[-1][-1]]>=0:
if d[-1].count(d[-1][-1]-a[d[-1][-1]])<times:g=1
if d[-1][-1]+a[d[-1][-1]]<=n:
if d[-1].count(d[-1][-1]+a[d[-1][-1]])<times:
if g>0: d.append(d[-1][:])
d[-1].append(d[-1][-1]+a[d[-1][-1]])
r=1
if g>0:
if r>0: d[-2].append(d[-2][-1]-a[d[-2][-1]])
else: d[-1].append(d[-1][-1]-a[d[-1][-1]])
r=1
if r==0:d.pop()
r, g=0, 0
a.append(v)
n+=1
if mode==0: print(n, a[n])
if mode>0:
u, q=0, []
while u<len(o):
q.append(a[o[u]])
u+=1
print(n, a[n], q, o)
return a
CROSSREFS
KEYWORD
nonn
AUTHOR
S. Brunner, Feb 13 2023
STATUS
approved