sympy.factorial2()方法
利用sympy.factorial2()方法,我们可以求出二重阶乘。一个数的双阶乘由-给出
语法:factorial2 (n)
参数:
n -表示需要计算其双阶乘的数。
返回值 – 返回数字的双阶乘,即n。
sympy.factorial2()方法 例# 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))
Output:
Value of n = 10
Double factorial of n : 3840
sympy.factorial2()方法 例# 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))
Output:
Value of n = -3
Double factorial of n : -1