What Is a Factorial?
A factorial, written as n!, is the product of all positive integers from 1 to n. For example, 5! = 5 x 4 x 3 x 2 x 1 = 120. By convention, 0! is defined as 1, which simplifies many combinatorial formulas. Factorials grow extremely fast—10! is already 3,628,800, and 20! exceeds 2.4 quintillion. This rapid growth is why factorials are central to understanding computational complexity and the limits of brute-force algorithms. The factorial function is one of the first recursive functions students learn, since n! = n x (n-1)!.
Why Factorials Matter
Factorials are the backbone of combinatorics and probability theory. The number of ways to arrange n distinct objects is n! (permutations). Combinations, binomial coefficients, and the binomial theorem all depend on factorials. In probability, factorials appear in the formulas for distributions like the Poisson and multinomial. Beyond pure mathematics, factorials are used in Taylor series expansions, Stirling's approximation, and the gamma function, which extends factorials to non-integer values.
Key Properties of Factorials
Important properties include: (1) n! = n x (n-1)! (recursive definition). (2) 0! = 1 (by convention). (3) n! grows faster than any exponential function. (4) Stirling's approximation: n! is approximately sqrt(2*pi*n) * (n/e)^n for large n. (5) The number of trailing zeros in n! equals the sum of floor(n/5^k) for k = 1, 2, 3... These properties make factorials a rich topic connecting algebra, analysis, and number theory.
Best Practices When Computing Factorials
For small values (n < 20), direct computation is straightforward. For large n, use libraries that support arbitrary precision integers, as standard floating-point will overflow. In programming, prefer iterative computation over recursion to avoid stack overflow. When you only need the ratio of factorials (like in combinations), cancel common factors before multiplying to avoid unnecessarily large intermediate values. Use logarithms of factorials (log-gamma function) when working with very large values in statistical computations.





