Factorial
How many hours are there in a day? \(4!\)
The factorial of a non-negative integer is the product of all positive integers less than or equal to that integer. Intuitively, \(n!\) is the number of unique sequences that can be made from \(n\) elements.
For the factorial of an integer \(n\), denoted \(n!\):
$$n! = n \times (n-1) \times (n-2) \times ... \times 3 \times 2 \times 1$$
Also, any factorial can be rewritten in terms of a smaller factorial:
$$n! = n \times (n-1)!$$
By convention, \(0! = 1.\) In other words, there is only \(1\) way to arrange \(0\) things, which is a fun way to think about it.
Contents
Recursive definition
Through recursion, the computation of any factorial can be whittled down to a single base case. Here's the recursive definition:
The factorial function \(f(n) = n!\) can be recursively defined for \(n \geq
1\):
$$f(0) = 1$$
$$f(n) = n \times f(n-1)$$