# Maple program for calculating the o.g.f. of row n in terms of u for the number T(n,k,t) of permutations of [n] # containing exactly k (possibly overlapping) occurrences of the consecutive pattern 123...(r+1)(r+3)(r+2) for r >= 0. # Here t = r + 2. B := proc(u, n, t) local v, s; option remember; if n = 0 then v := 1; end if; if 1 <= n then v := add((t*u - t)^s*pochhammer(1/t, s)*binomial(n, t*s + 1)*B(u, n - t*s - 1, t), s = 0 .. floor(n/t - 1/t)); end if; expand(v); end proc; T := proc(n, k, t) local v; if k = 0 then v := subs(u = 0, B(u, n, t)); end if; if 1 <= k then v := subs(u = 0, diff(B(u, n, t), u $ k))/k!; end if; v; end proc; rowT := proc(n, t) local k; seq(T(n, k, t), k = 0 .. max(0, floor((n - 1)/t))); end proc; colT := proc(k, max, t) local n; seq(T(n, k, t), n = 0 .. max); end proc;