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.

A228422 Number of permutations of [n] with exactly two (possibly overlapping) occurrences of some of the consecutive patterns 123, 1432, 2431, 3421.

Original entry on oeis.org

0, 0, 0, 0, 1, 14, 164, 1589, 15034, 139465, 1334945, 13108425, 134906641, 1443572465, 16238742806, 190546010823, 2347715040542, 30162115442344, 405859441345002, 5684963539755583, 83163913991455832, 1263763900212930657, 20000260465018111763
Offset: 0

Views

Author

Alois P. Heinz, Nov 09 2013

Keywords

Examples

			a(4) = 1: 1234.
a(5) = 14: 12354, 12453, 12543, 13452, 13542, 14532, 21345, 23451, 23541, 24531, 31245, 34521, 41235, 51234.
		

Crossrefs

Column k=2 of A231210.

Programs

  • Maple
    b:= proc(u, o, t, c) option remember;
          `if`(c<0, 0, `if`(u+o=0, `if`(c=0, 1, 0),
          add(b(u+j-1, o-j, [2, 2, 2][t], `if`(t=2, c-1, c)), j=1..o)+
          add(b(u-j, o+j-1, [1, 3, 1][t], `if`(t=3, c-1, c)), j=1..u)))
        end:
    a:= n-> b(n, 0, 1, 2):
    seq(a(n), n=0..25);
  • Mathematica
    b[u_, o_, t_, c_] := b[u, o, t, c] =
        If[c<0, 0, If[u+o == 0, If[c == 0, 1, 0],
        Sum[b[u+j-1, o-j, 2,              If[t == 2, c-1, c]], {j, 1, o}] +
        Sum[b[u-j, o+j-1, {1, 3, 1}[[t]], If[t == 3, c-1, c]], {j, 1, u}]]];
    a[n_] := b[n, 0, 1, 2];
    Table[a[n], {n, 0, 25}] (* Jean-François Alcover, Dec 20 2020, after Alois P. Heinz *)

Formula

a(n) ~ c * (2/Pi)^n * n! * n^2, where c = 1.286210080518397686... . - Vaclav Kotesovec, Aug 28 2014