What is a Factorial?
A factorial, denoted by n!, is the product of all positive integers from 1 to n. For example, 5! = 5 × 4 × 3 × 2 × 1 = 120. Factorials are fundamental in mathematics, particularly in counting, probability, and combinatorics.
The factorial function grows extremely rapidly. While 5! = 120, by the time you reach 10! you get 3,628,800, and 20! exceeds 2 quintillion. This rapid growth makes factorials important in complexity analysis and algorithm design.
By convention, 0! is defined as 1. This isn't intuitive, but it's necessary for many mathematical formulas to work correctly, especially in combinatorics where choosing 0 items from a set should give exactly 1 way (choosing nothing).
Common Factorial Values
Here are the first 15 factorial values for quick reference:
| n | n! | Digits | Uses |
| 0 | 1 | 1 | By definition |
| 1 | 1 | 1 | Base case |
| 5 | 120 | 3 | Hand arrangements |
| 7 | 5,040 | 4 | Week permutations |
| 10 | 3,628,800 | 7 | Digit arrangements |
| 12 | 479,001,600 | 9 | Month permutations |
| 15 | 1,307,674,368,000 | 13 | Large calculations |