A232435 Number T(n,k) of compositions of n with exactly k (possibly overlapping) occurrences of the consecutive pattern 111; triangle T(n,k), n>=0, 0<=k<=max(0,n-2), read by rows.
1, 1, 2, 3, 1, 7, 0, 1, 13, 2, 0, 1, 24, 5, 2, 0, 1, 46, 11, 4, 2, 0, 1, 89, 21, 11, 4, 2, 0, 1, 170, 45, 23, 11, 4, 2, 0, 1, 324, 99, 47, 23, 12, 4, 2, 0, 1, 618, 209, 102, 52, 23, 13, 4, 2, 0, 1, 1183, 427, 226, 112, 55, 24, 14, 4, 2, 0, 1, 2260, 883, 479
Offset: 0
Examples
T(4,0) = 7: [4], [3,1], [2,2], [1,3], [2,1,1], [1,2,1], [1,1,2]. T(7,1) = 11: [4,1,1,1], [2,2,2,1], [1,2,2,2], [1,1,1,4], [1,3,1,1,1], [2,2,1,1,1], [1,1,1,3,1], [2,1,1,1,2], [1,1,1,2,2], [1,1,1,2,1,1], [1,1,2,1,1,1]. T(7,2) = 4: [3,1,1,1,1], [1,1,1,1,3], [1,2,1,1,1,1], [1,1,1,1,2,1]. T(7,3) = 2: [2,1,1,1,1,1], [1,1,1,1,1,2]. T(7,5) = 1: [1,1,1,1,1,1,1]. Triangle T(n,k) begins: : 0 : 1; : 1 : 1; : 2 : 2; : 3 : 3, 1; : 4 : 7, 0, 1; : 5 : 13, 2, 0, 1; : 6 : 24, 5, 2, 0, 1; : 7 : 46, 11, 4, 2, 0, 1; : 8 : 89, 21, 11, 4, 2, 0, 1; : 9 : 170, 45, 23, 11, 4, 2, 0, 1; : 10 : 324, 99, 47, 23, 12, 4, 2, 0, 1;
Links
- Alois P. Heinz, Rows n = 0..150, flattened
Programs
-
Maple
b:= proc(n, t) option remember; `if`(n=0, 1, expand(add(`if`(abs(t)<>j, b(n-j, j), `if`(t<0, x, 1)*b(n-j, -j)), j=1..n))) end: T:= n->(p->seq(coeff(p, x, i), i=0..degree(p)))(b(n, 0)): seq(T(n), n=0..15);
-
Mathematica
b[n_, t_] := b[n, t] = If[n==0, 1, Expand[Sum[If[Abs[t] != j, b[n-j, j], If[t<0, x, 1]*b[n-j, -j]], {j, 1, n}]]]; T[n_] := Function[p, Table[ Coefficient[p, x, i], {i, 0, Exponent[p, x]}]][b[n, 0]]; Table[T[n], {n, 0, 15}] // Flatten (* Jean-François Alcover, Feb 08 2017, translated from Maple *)