Calculate factorials (n!) for any positive integer. Get instant results with step-by-step calculations and understand the mathematical properties of factorials.
A factorial, denoted as 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 combinatorics, probability theory, and calculus, where they appear in formulas for permutations, combinations, and series expansions.
Factorials have several important properties: 0! = 1 by definition, factorials grow extremely rapidly (faster than exponential functions), and they are only defined for non-negative integers. The rapid growth means that even relatively small numbers like 170! exceed the limits of standard computer arithmetic.
Factorials grow faster than exponential functions. While 2ⁿ grows exponentially, n! grows super-exponentially. This rapid growth makes factorials useful in analyzing algorithm complexity and understanding combinatorial explosion.
Factorials are essential for calculating permutations (n!/(n-r)!) and combinations (n!/(r!(n-r)!)). They determine the number of ways to arrange or select objects, fundamental in probability theory and discrete mathematics.
Taylor and Maclaurin series use factorials in their denominators. The exponential function eˣ = Σ(xⁿ/n!), sine and cosine functions, and many other important series rely on factorial terms for their expansions.
Algorithm analysis often involves factorial time complexity O(n!), particularly in problems like the traveling salesman problem. Factorials also appear in recursive algorithms and dynamic programming solutions.
0! = 1
1! = 1
2! = 2
3! = 6
4! = 24
5! = 120
6! = 720
7! = 5,040
8! = 40,320
9! = 362,880
10! = 3,628,800
As numbers increase, factorials become astronomically large. 20! has 19 digits, 50! has 65 digits, and 100! has 158 digits. The largest factorial that can be computed in standard JavaScript is 170!, which has 308 digits.
Due to the rapid growth of factorials, computational limits are quickly reached. For practical applications involving large numbers, approximations like Stirling's formula or logarithmic representations are often used instead of exact calculations.