The factorial of a non-negative integer n, denoted by n!, is the product of all positive integers less than or equal to n. For example, 5! = 5 × 4 × 3 × 2 × 1 = 120.
Factorials are fundamental in mathematics, particularly in combinatorics, probability, and calculus. They are used to calculate permutations, combinations, and appear in Taylor series expansions and the Gamma function.
To calculate n!:
For example, to calculate 5!:
5! = 5 × 4 × 3 × 2 × 1 = 120
Recursive definition:
Problem: Find the factorial of 6.
Solution:
Factorials grow extremely quickly:
By definition, 0! = 1. This makes mathematical formulas work consistently. For example, there is exactly one way to arrange zero objects (do nothing), and formulas like n!/((n-k)! × k!) work for all valid values including when k = 0 or k = n.
In standard JavaScript (which this calculator uses), factorials up to 170! can be accurately represented. 171! exceeds the maximum safe floating-point value. For larger factorials, special arbitrary-precision libraries are needed.
Factorials are essential in: calculating permutations (arrangements) and combinations (selections), probability calculations, Taylor series in calculus, and the Gamma function which extends factorials to non-integers.
Factorials are only defined for non-negative integers. However, the Gamma function extends the concept to other numbers, with Gamma(n) = (n-1)! for positive integers.