maths.special_numbers.catalan_number

Calculate the nth Catalan number

Source:

https://en.wikipedia.org/wiki/Catalan_number

Functions

catalan(→ int)

Module Contents

maths.special_numbers.catalan_number.catalan(number: int) int
Parameters:

number – nth catalan number to calculate

Returns:

the nth catalan number

Note: A catalan number is only defined for positive integers

>>> catalan(5)
14
>>> catalan(0)
Traceback (most recent call last):
    ...
ValueError: Input value of [number=0] must be > 0
>>> catalan(-1)
Traceback (most recent call last):
    ...
ValueError: Input value of [number=-1] must be > 0
>>> catalan(5.0)
Traceback (most recent call last):
    ...
TypeError: Input value of [number=5.0] must be an integer