The factorial of a nonnegative integer \(n\), written \(n!\), is one of the most important products in combinatorics.
It multiplies all positive integers from \(1\) to \(n\).
1. Definition of factorial
For \(n\ge1\),
\[
\begin{aligned}
n! &= 1\cdot2\cdot3\cdots n.
\end{aligned}
\]
Equivalently, it may be written in descending order:
\[
\begin{aligned}
n! &= n\cdot(n-1)\cdot(n-2)\cdots2\cdot1.
\end{aligned}
\]
Both forms give the same value because multiplication is commutative.
2. Special cases
The two smallest factorial values are
\[
\begin{aligned}
0! &= 1,\\
1! &= 1.
\end{aligned}
\]
The value \(0!=1\) may look surprising, but it is defined this way because it makes factorial formulas consistent.
In combinatorics, there is exactly one way to arrange zero objects: the empty arrangement.
3. Recursive formula
Factorials can also be defined recursively:
\[
\begin{aligned}
n! &= n\cdot(n-1)!,
\qquad n\ge1,\\
0! &= 1.
\end{aligned}
\]
This means each factorial is built from the previous one:
\[
\begin{aligned}
1! &= 1\cdot0! = 1,\\
2! &= 2\cdot1! = 2,\\
3! &= 3\cdot2! = 6,\\
4! &= 4\cdot3! = 24.
\end{aligned}
\]
4. Worked example: \(12!\)
To compute \(12!\), multiply every integer from \(1\) through \(12\):
\[
\begin{aligned}
12!
&=1\cdot2\cdot3\cdot4\cdot5\cdot6\cdot7\cdot8\cdot9\cdot10\cdot11\cdot12\\
&=479001600.
\end{aligned}
\]
Therefore:
\[
\begin{aligned}
\boxed{12!=479001600}.
\end{aligned}
\]
5. Factorials grow very quickly
Factorials grow faster than ordinary exponential sequences because every new step multiplies by a larger integer.
For example:
\[
\begin{aligned}
5! &= 120,\\
10! &= 3628800,\\
20! &= 2432902008176640000.
\end{aligned}
\]
This rapid growth is why large factorials can contain hundreds or thousands of digits.
6. Number of digits in \(n!\)
The number of decimal digits in a positive integer \(N\) is
\[
\begin{aligned}
\left\lfloor \log_{10}N \right\rfloor + 1.
\end{aligned}
\]
For a factorial:
\[
\begin{aligned}
\log_{10}(n!)
&=\log_{10}(1\cdot2\cdot3\cdots n)\\
&=\log_{10}1+\log_{10}2+\log_{10}3+\cdots+\log_{10}n.
\end{aligned}
\]
Therefore, for \(n!\ge1\):
\[
\begin{aligned}
\text{digits of }n!
&=\left\lfloor\sum_{k=1}^{n}\log_{10}k\right\rfloor+1.
\end{aligned}
\]
7. Trailing zeros in a factorial
A trailing zero is produced by a factor of \(10\).
Since
\[
\begin{aligned}
10 &= 2\cdot5,
\end{aligned}
\]
the number of trailing zeros depends on how many pairs of \(2\) and \(5\) occur in the prime factorization of \(n!\).
Factorials contain more factors of \(2\) than \(5\), so we only need to count factors of \(5\).
The formula is
\[
\begin{aligned}
Z(n!)
&=\left\lfloor\frac{n}{5}\right\rfloor
+\left\lfloor\frac{n}{25}\right\rfloor
+\left\lfloor\frac{n}{125}\right\rfloor
+\cdots.
\end{aligned}
\]
The sum stops when \(5^k>n\).
8. Example: trailing zeros of \(100!\)
\[
\begin{aligned}
Z(100!)
&=\left\lfloor\frac{100}{5}\right\rfloor
+\left\lfloor\frac{100}{25}\right\rfloor
+\left\lfloor\frac{100}{125}\right\rfloor\\
&=20+4+0\\
&=24.
\end{aligned}
\]
So \(100!\) ends with \(24\) zeros.
9. Factorials in permutations
The factorial \(n!\) counts the number of ways to arrange \(n\) distinct objects.
For example, three different letters \(A\), \(B\), and \(C\) can be arranged in
\[
\begin{aligned}
3! &= 6
\end{aligned}
\]
ways:
\[
\begin{aligned}
ABC,\ ACB,\ BAC,\ BCA,\ CAB,\ CBA.
\end{aligned}
\]
10. Factorials in combinations
Factorials are also used in combinations, where order does not matter:
\[
\begin{aligned}
\binom{n}{r}
&=\frac{n!}{r!(n-r)!}.
\end{aligned}
\]
They are also used in permutations:
\[
\begin{aligned}
P(n,r)
&=\frac{n!}{(n-r)!}.
\end{aligned}
\]
11. Approximation for large factorials
For large \(n\), Stirling’s approximation gives a useful estimate:
\[
\begin{aligned}
n! &\approx \sqrt{2\pi n}\left(\frac{n}{e}\right)^n.
\end{aligned}
\]
Taking base-10 logarithms gives:
\[
\begin{aligned}
\log_{10}(n!)
&\approx \frac{1}{2}\log_{10}(2\pi n)
+n\log_{10}\left(\frac{n}{e}\right).
\end{aligned}
\]
This approximation is useful for estimating the size of \(n!\), but the calculator computes the exact integer in the supported range.
12. Formula summary
| Concept |
Formula |
Meaning |
| Factorial |
\(n!=1\cdot2\cdot3\cdots n\) |
Product of all positive integers up to \(n\) |
| Special value |
\(0!=1\) |
Empty product and combinatorial convention |
| Recursive rule |
\(n!=n(n-1)!\) |
Builds each factorial from the previous one |
| Digits |
\(\left\lfloor\log_{10}(n!)\right\rfloor+1\) |
Number of decimal digits |
| Trailing zeros |
\(\sum_{k\ge1}\left\lfloor n/5^k\right\rfloor\) |
Counts factors of \(5\) in \(n!\) |
| Stirling approximation |
\(n!\approx\sqrt{2\pi n}(n/e)^n\) |
Estimates large factorials |
13. Common mistakes
- Forgetting that \(0!=1\), not \(0\).
- Writing \(n!\) as \(n\cdot n\) instead of \(n(n-1)(n-2)\cdots1\).
- Assuming factorials are defined for negative integers in elementary arithmetic.
- Underestimating how quickly factorials grow.
- Counting trailing zeros by looking only at one final multiplication instead of counting factors of \(5\).
Key idea: \(n!\) is a progressive product, and each new multiplier makes the result grow very quickly.