Python | sympy.subfactorial() method Last Updated : 14 Jul, 2019 Comments Improve Suggest changes Like Article Like Report With the help of sympy.subfactorial() method, we can find the Subfactorial of a number in SymPy. Subfactorial of a number is given by - !n = \begin{cases} 1 & n = 0 \\ 0 & n = 1 \\ (n-1)(!(n-1) + !(n-2)) & n > 1 \end{cases} 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: Python3 # 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)) Output: Value of n = 4 Subfactorial of n : 9 Example #2: Python3 # 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)) Output: Value of n = 9 Subfactorial of n : 133496 Comment More infoAdvertise with us Next Article Python | sympy.subfactorial() method R rupesh_rao Follow Improve Article Tags : Python SymPy Practice Tags : python Similar Reads Python | sympy.Rational() method With the help of sympy.Rational() method, we can find the rational form of any float value that is passed as parameter in sympy.Rational() method. Syntax : sympy.Rational(val) Return : Return Rational form of float value. Example #1 : In this example we can see that by using sympy.Rational() method, 1 min read Python sympy.subs() method sympy.subs() method in Python is used to substitute a variable or expression with a specified value or another expression in a symbolic mathematical expression. It is part of the SymPy library, which provides functionality for symbolic mathematics in Python, allowing you to work with equations, poly 3 min read Python | sympy.subs() method With the help of sympy.subs() method, we can substitute the value of variables in the various mathematical functions by using the sympy.subs() method. Syntax : sympy.subs(source, destination) Return : Return the same expression by changing the variable. Example #1 : In this example we can see that b 1 min read Python | sympy.solve() method With the help of sympy.solve(expression) method, we can solve the mathematical equations easily and it will return the roots of the equation that is provided as parameter using sympy.solve() method. Syntax : sympy.solve(expression) Return : Return the roots of the equation. Example #1 : In this exam 1 min read Python | sympy.symbols() method With the help of sympy.symbols() method, we can declare some variables for the use of mathematical expression and polynomials by using sympy.symbols() method. Syntax : sympy.symbols() Return : Return nothing or None. Example #1 : In this example we can see that by using sympy.symbols() method, we ar 1 min read Like