Clear[nn, t, n, k]; nn = 14; t[n_, 1] = If[n >= 1, n, 0]; t[1, k_] = 1; t[n_, k_] := t[n, k] = If[n > k, t[n - k, k], 0] + If[n <= k, Sum[t[n - 1, k - i], {i, 0, n - 1}] - Sum[t[n, k - i], {i, 1, n - 1}], 0]; TableForm[Table[Table[t[n, k], {k, 1, nn}], {n, 1, nn}]]; Flatten[Table[Table[t[n - k + 1, k], {k, 1, n}], {n, 1, nn}]]