%mathpiper,def="CatalanNumber"

CatalanNumber(_n) <--
[
	Check( IsPositiveInteger(n), "Argument", "CatalanNumber: Error: argument must be positive" );
	BinomialCoefficient(2*n,n)/(n+1);
];

%/mathpiper



%mathpiper_docs,name="CatalanNumber",categories="User Functions;Number Theory"
*CMD CatalanNumber --- return the {n}th Catalan Number
*STD
*CALL
	CatalanNumber(n)
*PARMS

{n}	-- positive integer

*DESC

This function returns the {n}-th Catalan number, defined as $BinomialCoefficient(2*n,n)/(n+1)$.

*E.G.

In> CatalanNumber(10)
Result: 16796;
In> CatalanNumber(5)
Result: 42;

*SEE BinomialCoefficient
%/mathpiper_docs