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.

A360594 a(n) is the maximum number of locations 0..n-1 which can be visited in a single path starting from i=n-1, where jumps from location i to i +- a(i) are permitted (within 0..n-1) and each location can be visited up to 2 times.

Original entry on oeis.org

0, 2, 1, 2, 4, 3, 8, 1, 2, 2, 4, 2, 8, 5, 4, 6, 13, 14, 14, 13, 13, 16, 22, 3, 17, 16, 20, 13, 13, 24, 22, 15, 24, 15, 14, 17, 14, 4, 15, 18, 23, 26, 28, 13, 16, 30, 28, 14, 15, 17, 16, 19, 16, 33, 18, 33, 32, 35, 39, 38, 40, 38, 39, 39, 36, 39, 38, 39, 41, 52
Offset: 0

Views

Author

S. Brunner, Feb 13 2023

Keywords

Comments

When a location is visited more than once, each such visit counts in a(n).

Examples

			For n=0 there are no locations 0..n-1, so the sole possible path is empty which is a(0) = 0 locations.
For n=1, the sole possible path is location 0 twice, 0 -> 0, which is 2 locations a(1) = 2.
For n=12, a path of a(12) = 8 locations visited starting from n-1 = 11 is:
  11 -> 9 -> 11 -> 9 -> 7 -> 8 -> 10 -> 6
Locations 11 and 9 are visited twice each and the others once.
  i    = 0  1  2  3  4  5  6  7  8  9 10 11
  a(i) = 0, 2, 1, 2, 4, 3, 8, 1, 2, 2, 4, 2
                                    2<----2
                                     ---->2
                              1<----2<----
                               ->2---->4
                           8<----------
		

Crossrefs

Programs

  • Python
    def A(lastn,times=2,mode=0):
      a,n=[0],0
      while n0:
          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]])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