sympy.subfactorial(n)方法
借助sympy.subfactorial()方法,我们可以在symy中找到某个数字的子阶乘。一个数的子阶乘由下面的式子给出
语法:subfactorial(n)
参数:
n -表示要计算其子阶乘的数。
返回number的子阶乘,即n。
sympy.subfactorial(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
sympy.subfactorial(n)方法 例# 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