Home  >  Article  >  Backend Development  >  How to use python factorial function

How to use python factorial function

(*-*)浩
(*-*)浩Original
2019-07-03 09:57:4723486browse

There are two factorial functions in python, and those created by yourself are not counted.

How to use python factorial function

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn