Python | sympy.catalan() method

With the help of sympy.catalan() method, we can find the Catalan number in SymPy. It is denoted as –

   C_n = \frac{1}{n+1} \binom{2n}{n}

Syntax: catalan(n)

Parameter:
n – It denotes the nth Catalan number.



Returns: Returns the nth Catalan number.

Example #1:

filter_none

edit
close

play_arrow

link
brightness_4
code

# import sympy 
from sympy import * n = 4
print("Value of n = {}".format(n))
   
# Use sympy.catalan() method 
nth_catalan = catalan(n)  
      
print("Value of nth catalan number : {}".format(nth_catalan))  

chevron_right


Output:

Value of n = 4
Value of nth catalan number : 14

Example #2:

filter_none

edit
close

play_arrow

link
brightness_4
code

# import sympy 
from sympy import * n = 15
print("Value of n = {}".format(n))
   
# Use sympy.catalan() method 
nth_catalan = catalan(n)  
      
print("Value of nth catalan number : {}".format(nth_catalan))  

chevron_right


Output:

Value of n = 15
Value of nth catalan number : 9694845


My Personal Notes arrow_drop_up

Recommended Posts:



    Article Tags :

    Be the First to upvote.


    Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.