Mastering Factorials (n!) in Modern Mathematics & Computation
The factorial function is one of the most fundamental operations in discrete mathematics, probability theory, statistics, computer science algorithm analysis, and quantum physics. Written as an integer followed by an exclamation mark (such as 6!), the factorial represents the product of all positive integers from 1 up to n.
Mathematical Properties of n!
Factorials exhibit unique mathematical properties that make them essential in combinatorics and analysis:
- Recurrence Relation: n! = n × (n - 1)! for all n ≥ 1.
- Empty Product Identity: 0! = 1. This allows combinatorial formulas such as C(n, 0) = n! / (0! × n!) = 1 to hold true universally.
- Gamma Function Extension: The factorial function can be extended to all complex and real numbers (except negative integers) through Euler's Gamma Function: Γ(n + 1) = n!. For example, (1/2)! = Γ(3/2) = √π / 2 ≈ 0.8862.
- Legendre's Formula for Prime Divisors: The exponent of any prime p dividing n! is given by E_p(n!) = ⌊n/p⌋ + ⌊n/p²⌋ + ⌊n/p³⌋ + .... This efficiently determines trailing zeros by calculating the multiplicity of prime factor 5.
Permutations and Combinations
Factorials are the backbone of counting and probability:
Permutations P(n, r) = n! / (n - r)! — The number of ways to arrange r items from a collection of n where sequence/order is critical.
Combinations C(n, r) = n! / [r!(n - r)!] — The number of unordered subsets of size r from n items.
Frequently Asked Questions (FAQ)
BigInt arithmetic, enabling exact digit-by-digit computation for factorials up to 2000! without loss of numeric precision.