- The factorial of a non-negative integer
n
is the product of all positive integers less than or equal ton
. It is denoted asn!
.
n! = n × (n - 1) × (n - 2) × ... × 1
- Special case:
0! = 1
(by definition)
Examples:
5! = 5 × 4 × 3 × 2 × 1 = 120
3! = 3 × 2 × 1 = 6
0! = 1
- Running with an instance included:
python instance.py