with(combinat);
for i from 1 to 15 do pik(i, 3) od;
pik:= proc(n::integer, k::integer)
local i, Liste, Result;
if k > n or n < 0 or k < 1 then
return fail
end if;
Result := 0;
for i from k to n do
Liste:= PartitionList(n, i);
#print(Liste);
Result := Result + nops(Liste);
end do;
return Result;
end proc;
PartitionList := proc (n, k)
# Authors: Herbert S. Wilf and Joanna Nordlicht. Source: Lecture Notes
# "East Side West Side, ..." University of Pennsylvania, USA, 2002.
# Available at: http://www.cis.upenn.edu/~wilf/lecnotes.html
# Calculates the partition of n into k parts.
# E.g. PartitionList(5, 2) --> [[4, 1], [3, 2]].
local East, West;
if n < 1 or k < 1 or n < k then
RETURN([])
elif n = 1 then
RETURN([[1]])
else if n < 2 or k < 2 or n < k then
West := []
else
West := map(proc (x) options operator, arrow;
[op(x), 1] end proc, PartitionList(n-1, k-1)) end if;
if k <= n-k then
East := map(proc (y) options operator, arrow;
map(proc (x) options operator, arrow; x+1 end proc, y) end proc, PartitionList(n-k, k))
else East := [] end if;
RETURN([op(West), op(East)])
end if;
end proc;
ZL :=[S, {S = Set(Cycle(Z), 3 <= card)}, unlabelled]: seq(combstruct[count](ZL, size=n), n=1..41); #
Zerinvary Lajos, Mar 25 2008
B:=[S, {S = Set(Sequence(Z, 1 <= card), card >=3)}, unlabelled]: seq(combstruct[count](B, size=n), n=1..41); #
Zerinvary Lajos, Mar 21 2009