Factorials: The Building Blocks of Combinatorics
The factorial of a non-negative integer n, written as n!, is the product of all positive integers from 1 to n. For example, 5! = 5 × 4 × 3 × 2 × 1 = 120. By convention, 0! = 1, which may seem surprising but is essential for combinatorial formulas to work correctly. Factorials grow extraordinarily fast — so fast that 170! is the largest factorial that fits in a standard floating-point number, and 100! has 158 digits. Factorials are fundamental to permutations, combinations, probability, Taylor series, and many areas of mathematics and computer science.
Factorial Formulas and Properties
Convention: 0! = 1, 1! = 1
Recursive: n! = n x (n-1)!
Stirling's Approximation (large n):
n! ~ sqrt(2*pi*n) x (n/e)^n
Trailing Zeros (from factors of 5):
zeros = floor(n/5) + floor(n/25) + floor(n/125) + ...
Log of Factorial:
log10(n!) = sum of log10(k) for k=1 to n
Digits in n! = floor(log10(n!)) + 1
Related Functions:
Permutation: P(n,r) = n! / (n-r)!
Combination: C(n,r) = n! / (r!(n-r)!)
Gamma: n! = Gamma(n+1) for integers
Applications of Factorials
Factorials appear wherever you count arrangements. The number of ways to arrange n distinct objects in a row is n!. In probability, the binomial coefficient C(n,k) = n!/(k!(n-k)!) counts how many ways to choose k items from n. Taylor series use factorials in denominators: ex = ∑ xn/n!. In cryptography, the security of certain systems depends on the enormous size of factorials. Computer science uses factorials in algorithm analysis — algorithms with O(n!) complexity are considered intractable for large n because factorial growth outpaces exponential growth.