Python | sympy.subfactorial() method

With the help of sympy.subfactorial() method, we can find the Subfactorial of a number in SymPy. Subfactorial of a number is given by –

Syntax: subfactorial(n)
Parameter:
n – It denotes the number whose subfactorial is to be calculated.Returns: Returns the subfactorial of number, i. e., n.
Example #1:
| # import sympy  fromsympy import* n =4print("Value of n = {}".format(n))   # Use sympy.subfactorial() method  subfactorial_n =subfactorial(n)        print("Subfactorial of n : {}".format(subfactorial_n))    | 
Output:
Value of n = 4 Subfactorial of n : 9
Example #2:
| # import sympy  fromsympy import* n =9print("Value of n = {}".format(n))   # Use sympy.subfactorial() method  subfactorial_n =subfactorial(n)        print("Subfactorial of n : {}".format(subfactorial_n))    | 
Output:
Value of n = 9 Subfactorial of n : 133496
 
				 
					


