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.

Showing 1-2 of 2 results.

A333833 Number of permutations p of [n] such that |p(i) - p(i-1)| <= 2 and |p(i) - p(i-2)| <= 3.

Original entry on oeis.org

1, 1, 2, 6, 12, 14, 18, 28, 42, 56, 74, 102, 144, 200, 274, 376, 520, 720, 994, 1370, 1890, 2610, 3604, 4974, 6864, 9474, 13078, 18052, 24916, 34390, 47468, 65520, 90436, 124826, 172294, 237814, 328250, 453076, 625370, 863184, 1191434, 1644510, 2269880, 3133064
Offset: 0

Views

Author

Alois P. Heinz, Apr 07 2020

Keywords

Examples

			a(5) = 14: 12345, 12354, 12435, 12453, 13245, 21345, 31245, 35421, 45321, 53421, 54213, 54231, 54312, 54321.
a(6) = 18: 123456, 123465, 123546, 123564, 124356, 132456, 213456, 213465, 312456, 465321, 564312, 564321, 645321, 653421, 654213, 654231, 654312, 654321.
		

Crossrefs

Programs

  • Mathematica
    Join[{1, 1, 2, 6, 12}, LinearRecurrence[{1, 0, 0, 1}, {14, 18, 28, 42}, 40]] (* Jean-François Alcover, Oct 26 2021 *)

Formula

G.f.: -(2*x^8+4*x^7+2*x^6+x^5+5*x^4+4*x^3+x^2+1)/(x^4+x-1).
a(n) = 2*A302510(n-2) for n >= 6.
Limit_{n-> infinity} a(n+1)/a(n) = A086106.

A338738 Number of permutations p of [n] such that |p(i) - p(i-1)| <= |p(i+1) - p(i)|.

Original entry on oeis.org

1, 1, 2, 4, 6, 8, 10, 14, 20, 24, 32, 40, 48, 70, 94, 126, 162, 228, 292, 386, 528, 710, 956, 1298, 1730, 2342, 3178, 4192, 5684, 7720, 10340, 14002, 18816, 25372, 34054
Offset: 0

Views

Author

Alois P. Heinz, Nov 05 2020

Keywords

Examples

			a(4) = 6: 1234, 2314, 2341, 3214, 3241, 4321.
		

Crossrefs

Cf. A338614.

Programs

  • Maple
    b:= proc(s, x, y) option remember; `if`(s={}, 1, add(
          `if`(x=0 or y=0 or abs(x-y)<=abs(y-j),
             b(s minus {j}, y, j), 0), j=s))
        end:
    a:= n-> b({$1..n}, 0$2):
    seq(a(n), n=0..16);
  • Mathematica
    b[s_, x_, y_] := b[s, x, y] = If[s == {}, 1, Sum[If[x == 0 || y == 0 || Abs[x - y] <= Abs[y - j], b[s ~Complement~ {j}, y, j], 0], {j, s}]];
    a[n_] := b[Range[n], 0, 0];
    Table[Print[n, " ", a[n]]; a[n], {n, 0, 20}] (* Jean-François Alcover, Sep 08 2021, after Alois P. Heinz *)

Extensions

a(27)-a(34) from Bert Dobbelaere, Nov 15 2020
Showing 1-2 of 2 results.