OFFSET
0,3
LINKS
Alois P. Heinz, Table of n, a(n) for n = 0..250
Wikipedia, Partition of a set
EXAMPLE
a(0) = 1: () the empty partition.
a(1) = 0.
a(2) = 2: 12, 1|2.
a(3) = 2: 123, 13|2.
a(4) = 9: 1234, 12|34, 12|3|4, 13|24, 14|23, 1|23|4, 14|2|3, 1|2|34, 1|2|3|4.
a(5) = 23: 12345, 123|45, 123|4|5, 125|34, 12|345, 125|3|4, 12|35|4, 134|25, 134|2|5, 135|24, 13|25|4, 13|2|45, 13|2|4|5, 145|23, 14|235, 15|23|4, 1|235|4, 145|2|3, 14|2|35, 15|2|34, 1|2|345, 15|2|3|4, 1|2|35|4.
MAPLE
b:= proc(n, x, y, m) option remember; `if`(n=0, `if`(x=y, 1, 0),
`if`(x+m>0, b(n-1, y, x, m)*(x+m), 0)+b(n-1, y, x+1, m)+
`if`(y>0, b(n-1, y-1, x, m+1)*y, 0))
end:
a:= n-> b(n, 0$3):
seq(a(n), n=0..28);
MATHEMATICA
b[n_, x_, y_, m_] := b[n, x, y, m] = If[n == 0, If[x == y, 1, 0], If[x + m > 0, b[n - 1, y, x, m]*(x + m), 0] + b[n - 1, y, x + 1, m] + If[y > 0, b[n - 1, y - 1, x, m + 1]*y, 0]];
a[n_] := b[n, 0, 0, 0];
Table[a[n], {n, 0, 28}] (* Jean-François Alcover, Oct 20 2023, after Alois P. Heinz *)
CROSSREFS
KEYWORD
nonn
AUTHOR
Alois P. Heinz, Jun 02 2023
STATUS
approved