Python| sympy.subfactorial() 方法
在sympy.subfactorial()方法的帮助下,我们可以在 SymPy 中找到一个数的 Subfactorial。一个数字的子阶乘由下式给出 -
Syntax: subfactorial(n)
Parameter:
n – It denotes the number whose subfactorial is to be calculated.
Returns: Returns the subfactorial of number, i. e., n.
示例 #1:
# import sympy
from sympy import *
n = 4
print("Value of n = {}".format(n))
# Use sympy.subfactorial() method
subfactorial_n = subfactorial(n)
print("Subfactorial of n : {}".format(subfactorial_n))
输出:
Value of n = 4
Subfactorial of n : 9
示例 #2:
# import sympy
from sympy import *
n = 9
print("Value of n = {}".format(n))
# Use sympy.subfactorial() method
subfactorial_n = subfactorial(n)
print("Subfactorial of n : {}".format(subfactorial_n))
输出:
Value of n = 9
Subfactorial of n : 133496