login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A360593 Each term a(i) can reach a(i+a(i)) and a(i-a(i)) if these terms exist. a(n) is the greatest number of terms among a(1..n-1) that can be reached by starting at a(n-1) and visiting no term more than once; a(0)=0. See example. 10

%I #45 Feb 25 2023 08:20:17

%S 0,1,2,2,4,2,6,2,7,5,6,6,9,10,10,6,8,7,9,8,11,8,12,14,12,14,19,16,19,

%T 14,14,16,14,21,14,16,21,14,14,16,14,18,14,16,21,21,19,21,22,22,21,23,

%U 24,24,29,29,22,26,24,28,24,26,31,24,31,34,24,30,34,29,39

%N Each term a(i) can reach a(i+a(i)) and a(i-a(i)) if these terms exist. a(n) is the greatest number of terms among a(1..n-1) that can be reached by starting at a(n-1) and visiting no term more than once; a(0)=0. See example.

%C For clarification:

%C 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.

%C 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:

%C C3 = a(n-1-C1-C2) or a(n-1-C1+C2),

%C C4 = a(n-1-C1{-/+}C2{-/+}C3), etc.

%C The first numbers which appear to be missing from this sequence are:

%C 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.

%H S. Brunner, <a href="/A360593/b360593.txt">Table of n, a(n) for n = 0..217</a>

%e This example shows the longest chain of jumps starting with a(7)=2:

%e 0, 1, 2, 2, 4, 2, 6, 2

%e 1<----2<----2<----2

%e ->2---->4

%e 0<----------

%e It visited the 7 terms 2,2,2,1,2,4,0. So a(8)=7.

%o (Python)

%o def A(lastn,times=1,mode=0):

%o a,n=[0],0

%o while n<lastn:

%o d,i,v,o,g,r=[[n]],0,1,[],0,0

%o while len(d)>0:

%o if len(d[-1])>v: v,o=len(d[-1]),d[-1][:]

%o if d[-1][-1]-a[d[-1][-1]]>=0:

%o if d[-1].count(d[-1][-1]-a[d[-1][-1]])<times:g=1

%o if d[-1][-1]+a[d[-1][-1]]<=n:

%o if d[-1].count(d[-1][-1]+a[d[-1][-1]])<times:

%o if g>0: d.append(d[-1][:])

%o d[-1].append(d[-1][-1]+a[d[-1][-1]])

%o r=1

%o if g>0:

%o if r>0: d[-2].append(d[-2][-1]-a[d[-2][-1]])

%o else: d[-1].append(d[-1][-1]-a[d[-1][-1]])

%o r=1

%o if r==0:d.pop()

%o r,g=0,0

%o a.append(v)

%o n+=1

%o if mode==0: print(n,a[n])

%o if mode>0:

%o u,q=0,[]

%o while u<len(o):

%o q.append(a[o[u]])

%o u+=1

%o print(n,a[n],q,o)

%o return a

%Y Cf. A360594, A360595, A360744, A360745, A360746.

%K nonn

%O 0,3

%A _S. Brunner_, Feb 13 2023

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified June 20 20:42 EDT 2024. Contains 373532 sequences. (Running on oeis4.)