recurse :=
proc(n, q, k)
option remember;
local res, l, m;

    if q = 0 then
        if n = 0 then
            return 1
        else
            return 0;
        fi;
    fi;

    if q = 1 then return T(n, k) fi;

    res := 0;

    for l to q do
        for m from 0 to floor(n/l) do
            res :=
            res +
            1/q*T(m, k)*
            recurse(n-m*l, q-l, k);
        od;
    od;

    res;
end;


T :=
proc(n, k)
option remember;

    if n <= 1 then return 1 fi;
    if k = 1 then return 1 fi;

    recurse(n-1, k, k);
end;