Partition numbers with Gary W. Adamsons aerate convolve algorithm

Mathematica 8


Clear[t, A, B]
nn = 16;
A = Table[Table[If[n >= k, 1, 0], {k, 1, nn}], {n, 1, nn}];
MatrixForm[A];
B = A;
Do[
Clear[t, A];
t[n_, k_] :=
t[n, k] =
If[k == 1, If[Mod[n, j] == 1, 1, 0],
If[n >= k, t[n - 1, k - 1], 0]];
A = Table[Table[t[n, k], {k, 1, nn}], {n, 1, nn}];
B = B.A;
(*Print[MatrixForm[B]]*)
, {j, 2, nn}]
B[[All, 1]]

{1, 1, 2, 3, 5, 7, 11, 15, 22, 30, 42, 56, 77, 101, 135, 176}

Advertisements
This entry was posted in Uncategorized. Bookmark the permalink.