%mathpiper,def="StirlingNumber2"

10 # StirlingNumber2(n_IsInteger,0) <-- If(n=0,1,0);
20 # StirlingNumber2(n_IsInteger,k_IsInteger) <-- Sum(i,0,k-1,(-1)^i*BinomialCoefficient(k,i)*(k-i)^n)/ k! ;

%/mathpiper



%mathpiper_docs,name="StirlingNumber2",categories="User Functions;Number Theory"
*CMD StirlingNumber2 --- return the {n m}th Stirling Number of the second kind
*STD
*CALL
        StirlingNumber1(n,m)
*PARMS

{n}, {m}        -- positive integers

*DESC

This function returns the Stirling Number of the second kind.
All Stirling Numbers are positive integers. If $ m > n $, then {StirlingNumber2} returns
$0$.

*E.G.

In> StirlingNumber2(3,6)
Result: 0;
In> StirlingNumber2(10,4)
Result: 34105;

*SEE StirlingNumber1
%/mathpiper_docs