%mathpiper,def="StirlingNumber1"

10 # StirlingNumber1(n_IsInteger,0) <-- If(n=0,1,0);
10 # StirlingNumber1(n_IsInteger,1) <-- (-1)^(n-1)*(n-1)!;
10 # StirlingNumber1(n_IsInteger,2) <-- (-1)^n*(n-1)! * HarmonicNumber(n-1);
10 # StirlingNumber1(n_IsInteger,n-1) <-- -BinomialCoefficient(n,2);
10 # StirlingNumber1(n_IsInteger,3) <-- (-1)^(n-1)*(n-1)! * (HarmonicNumber(n-1)^2 - HarmonicNumber(n-1,2))/2;
20 # StirlingNumber1(n_IsInteger,m_IsInteger) <--
	Sum(k,0,n-m,(-1)^k*BinomialCoefficient(k+n-1,k+n-m)*BinomialCoefficient(2*n-m,n-k-m)*StirlingNumber2(k-m+n,k));

%/mathpiper



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

{n}, {m}	-- positive integers

*DESC

This function returns the signed Stirling Number of the first kind.
All Stirling Numbers are integers. If $ m > n $, then {StirlingNumber1} returns
$0$.

*E.G.

In> StirlingNumber1(10,5)
Result: -269325;
In> StirlingNumber1(3,6)
Result: 0;

*SEE StirlingNumber2
%/mathpiper_docs