Python sympy.factorial2()方法
在sympy.factorial2()方法的帮助下,我们可以找到双阶乘。一个数字的双阶乘的计算方法是 –
语法: factorial2(n)
参数 :
n –它表示要计算其双阶乘的数字。
返回:返回数字的双阶乘,即n。
示例 #1:
# import sympy
from sympy import *
n = 10
print("Value of n = {}".format(n))
# Use sympy.factorial2() method
factorial2_n = factorial2(n)
print("Double factorial of n : {}".format(factorial2_n))
输出:
Value of n = 10
Double factorial of n : 3840
示例 #2:
# import sympy
from sympy import *
n = -3
print("Value of n = {}".format(n))
# Use sympy.factorial2() method
factorial2_n = factorial2(n)
print("Double factorial of n : {}".format(factorial2_n))
输出:
Value of n = -3
Double factorial of n : -1