
MATHEMATICA

Clear[u, v, w]; w[0] = w[1] = 1; w[n_] /; n >= 2 := w[n] = u[n] + v[n];
v[n_] /; n >= 2 := v[n] = Sum[v[n, a], {a, 2, n}]; v[1, 1] = 1;
v[n_, a_] /; 2 <= a <= n :=
v[n, a] = Sum[u[n  1, b], {b, a  1}] + Sum[v[n  1, b], {b, 2, a  1}];
u[1] = 1; u[n_] /; n >= 2 := u[n] = Sum[u[n, a], {a, n  1}]; u[1, 1] = 1;
u[n_, a_] /; a == n := 0; u[n_, a_] /; 1 <= a < n := u[n, a, n];
u[1, 1, k_] := 1; u[2, 1, k_] := 1; u[n_, a_, k_] /; a >= n := 0;
u[n_, a_, k_] /; 1 <= a < n && n >= 3 :=
u[n, a, k] = Sum[u[n, a, k, b], {b, a + 1, n}];
u[n_, a_, k_, b_] /; 1 <= a < b <= n && k >= b + 2 := u[n, a, b + 1, b];
u[n_, a_, k_, b_] /; 1 <= a < n && b == n && k == n + 1 := u[n, a, n, n];
u[n_, a_, k_, b_] /; 1 == a < b == n && k == 2 := 1;
u[n_, a_, k_, b_] /; 1 <= a < b <= n && k <= b :=
u[n, a, k, b] =
Sum[Binomial[b  k  If[k <= a, 1, 0], j1] Binomial[
k  1  If[a < k, 1, 0]  c, j2]*
u[n  2  j1  j2, c, k  If[a < k, 1, 0]  j2], {c,
k  1  If[a < k, 1, 0]}, {j1, 0, b  k  If[k <= a, 1, 0]}, {j2, 0,
k  1  If[a < k, 1, 0]  c}];
u[n_, a_, k_, b_] /; 1 <= a < b < n && k == b + 1 && {a, b} == {1, 2} := 1;
u[n_, a_, k_, b_] /; 1 <= a < b < n && k == b + 1 && {a, b} != {1, 2} :=
u[n, a, k, b] =
Sum[Binomial[n  b, i] Binomial[b  2  c, j] u[n  2  i  j, c,
b  1  j], {c, b  2}, {i, 0, n  b}, {j, 0, b  2  c}]; Table[
w[n], {n, 0, 15}]
