There are two factorial functions in python, and those created by yourself are not counted.
The first is the factorial function in the numpy library (recommended learning: Python video tutorial)
improt numpy print numpy.math.factorial(3)
Second, the standard library that comes with python also has the factorial function
import math print math.factorial(3)
Example:
#由于第一种需要下载库,我们使用第二种 import math value = math.factorial(3) print(value)
Output:
6
For more Python-related technical articles, please visit the Python Tutorial column to learn!
The above is the detailed content of How to use python factorial function. For more information, please follow other related articles on the PHP Chinese website!