combinat::catalan – Catalan numbers

combinat::catalan(n) returns the n-th Catalan number.

→ Examples

Call:

combinat::catalan(n)

Parameters:

n

nonnegative integer

Return Value:

A positive integer.

Details:

Example 1:

We compute the math-th Catalan number:

combinat::catalan(5)

math

Correct answer. But what was the question ?

Example 2:

We compute the first Catalan numbers:

combinat::catalan(n) $ n = 0..6

math

They coincide with the number of Dyck words:

combinat::dyckWords::count(n) $ n = 0..6

math

They also coincide with the numbers of tableaux with two rows or two columns of the same size:

1, nops(combinat::tableaux::list([2 $ n])) $ n = 1..6;

1, nops(combinat::tableaux::list([n $ 2])) $ n = 1..6;

math

math

Example 3:

If one uses a wrong argument, an error message is returned

combinat::catalan(-1)

Error: Wrong type of 1. argument (type 'Type::NonNegInt' expected,

       got argument '-1');

during evaluation of 'combinat::catalan'