Python | sympy.genocchi() method

With the help of sympy.genocchi() method, we can find Genocchi numbers in SymPy.

genocchi(n) -


The Genocchi numbers are a sequence of integers Gn that satisfy the relation \frac{2t}{e^t + 1} = \sum_{n=1}^\infty \frac{G_n t^n}{n!}.



Syntax: genocchi(n)

Parameter:
n – It denotes the number upto which genocchi number is to be calculated.

Returns: Returns the nth genocchi number.

Example #1:

filter_none

edit
close

play_arrow

link
brightness_4
code

# import sympy 
from sympy import * 
  
n = 7
print("Value of n = {}".format(n))
   
# Use sympy.genocchi() method 
nth_genocchi = genocchi(n)  
      
print("Value of nth genocchi number : {}".format(nth_genocchi))  

chevron_right


Output:

Value of n = 7
Value of nth genocchi number : 0

Example #2:

filter_none

edit
close

play_arrow

link
brightness_4
code

# import sympy 
from sympy import * 
  
n = 10
print("Value of n = {}".format(n))
   
# Use sympy.genocchi() method 
n_genocchi = [genocchi(x) for x in range(1, 11)]  
      
print("N genocchi number are : {}".format(n_genocchi))  

chevron_right


Output:

Value of n = 10
N genocchi numbers are : [1, -1, 0, 1, 0, -3, 0, 17, 0, -155]


My Personal Notes arrow_drop_up

Coder Machine Learner Social Activist Vocalist

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.




Article Tags :

Be the First to upvote.


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