Python | sympy.genocchi() method
Last Updated :
26 Jul, 2019
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
.
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:
from sympy import *
n = 7
print ( "Value of n = {}" . format (n))
nth_genocchi = genocchi(n)
print ( "Value of nth genocchi number : {}" . format (nth_genocchi))
|
Output:
Value of n = 7
Value of nth genocchi number : 0
Example #2:
from sympy import *
n = 10
print ( "Value of n = {}" . format (n))
n_genocchi = [genocchi(x) for x in range ( 1 , 11 )]
print ( "N genocchi number are : {}" . format (n_genocchi))
|
Output:
Value of n = 10
N genocchi numbers are : [1, -1, 0, 1, 0, -3, 0, 17, 0, -155]
Share your thoughts in the comments
Please Login to comment...