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.

A356832 Number of permutations p of [n] such that at most one element of {p(1),...,p(i-1)} is between p(i) and p(i+1) for all i < n and n = 0 or p(n) < 3.

Original entry on oeis.org

1, 1, 2, 4, 10, 26, 72, 206, 608, 1834, 5636, 17578, 55516, 177192, 570700, 1852572, 6055080, 19910730, 65823752, 218654100, 729459552, 2443051214, 8210993364, 27685671844, 93625082140, 317470233150, 1079183930828, 3676951654520, 12554734605496, 42952566314236
Offset: 0

Views

Author

Alois P. Heinz, Aug 30 2022

Keywords

Examples

			a(0) = 1: (), the empty permutation.
a(1) = 1: 1.
a(2) = 2: 12, 21.
a(3) = 4: 132, 231, 312, 321.
a(4) = 10: 1342, 1432, 2431, 3142, 3412, 3421, 4132, 4231, 4312, 4321.
a(5) = 26: 13542, 14532, 15342, 15432, 24531, 25431, 31542, 35142, 35412, 35421, 41532, 42531, 45132, 45231, 45312, 45321, 51342, 51432, 52431, 53142, 53412, 53421, 54132, 54231, 54312, 54321.
		

Crossrefs

Column k=0 and also main diagonal of A356692.

Programs

  • Maple
    b:= proc(u, o) option remember; `if`(u+o=0, 1,
          add(b(sort([o-j, u+j-1])[]), j=1..min(2, o))+
          add(b(sort([u-j, o+j-1])[]), j=1..min(2, u)))
        end:
    a:= n-> b(0, n):
    seq(a(n), n=0..30);
    # second Maple program:
    b:= proc(n, k) option remember; `if`(k<0 or k>n, 0,
          `if`(n=0, 1, add(b(n-1, j), j=k-2..k+1)))
        end:
    a:= n-> b(n, 0):
    seq(a(n), n=0..30);

Formula

a(n) = A356692(n,0) = A356692(n,n).
a(n) = 1 + A291683(n).
a(n) >= A102407(n) with equality only for n <= 7.