On this page
math.factorial
Prev: math.fabs | Up: math | Next: math.floor
Rel: math.acos, math.acosh, math.asin, math.asinh
Ref: docs.python.org — math.factorial
Tags: #public #python3 #stdlib #math
Import
import math
from math import factorial
Signature & Overview
math.factorial(n, /)
Find n!.
Usage
import math
assert math.factorial(5) == 120
assert math.factorial(0) == 1
Gotchas
- Non-negative integers only: Negative numbers and floats raise
ValueError/TypeError(usemath.gamma(x + 1)for non-integers).
REPL Inspect
from math import factorial
help(factorial)
Linked from
Related notes
- tuts/python3/stdlib_module/math/fabs Linked here; links to this page; shared tags: #math, #stdlib
- tuts/python3/stdlib_module/math/floor Linked here; links to this page; shared tags: #math, #stdlib
- tuts/python3/stdlib_module/math Linked here; links to this page; shared tags: #stdlib
- tuts/python3/stdlib_module/math/acos Linked here; shared tags: #math, #stdlib
- tuts/python3/stdlib_module/math/acosh Linked here; shared tags: #math, #stdlib
- tuts/python3/stdlib_module/math/asin Linked here; shared tags: #math, #stdlib
- tuts/python3/stdlib_module/math/asinh Linked here; shared tags: #math, #stdlib
- tuts/c/stdlib/math shared tags: #math, #stdlib
- tuts/c/stdlib/math/fabs shared tags: #math, #stdlib
- tuts/c/stdlib/math/floor shared tags: #math, #stdlib