Calculate factorial (n!) of any number with step-by-step breakdown.
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. Factorials grow incredibly rapidly — 20! exceeds 2 quintillion. Our factorial calculator computes n! instantly for any non-negative integer, even very large ones.
n! = n × (n-1) × (n-2) × ... × 2 × 1. Special cases: 0! = 1 (by convention — one way to arrange zero items). 1! = 1. 2! = 2. 3! = 6. 4! = 24. 5! = 120. 10! = 3,628,800. 20! = 2,432,902,008,176,640,000. The recursive definition: n! = n × (n-1)! is foundational in computer science.
Factorials are the foundation of counting problems. Permutations (arrangements where order matters): P(n,r) = n! / (n-r)! — ways to arrange r items from n. Combinations (selections where order does not matter): C(n,r) = n! / (r! × (n-r)!) — ways to choose r items from n. These formulas are used in probability, statistics, and combinatorics.
Factorials appear in Taylor series expansions used to approximate functions: e^x = 1 + x + x²/2! + x³/3! + ... sin(x) = x − x³/3! + x⁵/5! − ... cos(x) = 1 − x²/2! + x⁴/4! − ... These infinite series are how calculators and computers internally compute transcendental functions like e^x, sin, and cos.
For very large n, computing n! directly requires enormous numbers. Stirling's approximation gives a close estimate: n! ≈ √(2πn) × (n/e)^n. This is used in statistical mechanics, information theory, and any field dealing with large combinatorial numbers. For programming, use logarithms of factorials (log(n!)) to avoid overflow when working with very large n.
A factorial (written as n!) represents the number of ways to arrange n distinct items in order — 5! equals 120, meaning there are exactly 120 different ways to arrange 5 distinct objects in a sequence. This makes factorials fundamental to combinatorics, probability, and statistics, since counting arrangements and combinations is a core building block for calculating odds, permutations, and probability distributions used across science, gaming, and cryptography.
Factorials grow extraordinarily fast — 10! is already 3,628,800, and 20! exceeds 2.4 quintillion, far beyond what most calculators can display without switching to scientific notation. This explosive growth rate is actually useful to understand intuitively, since it explains why brute-force approaches to problems involving large permutations (like certain cryptographic or scheduling problems) become computationally infeasible past a relatively small number of items.
Factorials underpin the formulas for permutations (ordered arrangements) and combinations (unordered selections), both of which are essential for calculating probabilities in card games, lottery odds, and statistical sampling. The combination formula, which divides a factorial by the product of two smaller factorials, is what makes it possible to calculate, for example, exactly how many different 5-card poker hands exist from a standard 52-card deck — a calculation that would be essentially impossible to work out by simple counting.
By mathematical convention, 0! is defined as equal to 1, not 0, which often confuses people encountering it for the first time. This definition exists because it keeps combinatorial formulas consistent — there is exactly one way to arrange zero items (the empty arrangement), and defining 0! as 1 makes formulas involving factorials work correctly at their boundary conditions without requiring special-case exceptions.
Factorial growth is frequently used in computer science as a benchmark example of extremely poor algorithmic efficiency — an algorithm with factorial time complexity becomes impractically slow for even modest input sizes, which is why computer scientists specifically try to avoid factorial-complexity solutions when designing efficient algorithms for problems like scheduling or route optimization.
Factorial of a number n (written as n!) is the product of all positive integers from 1 to n. For example, 5! = 5 × 4 × 3 × 2 × 1 = 120.
0! = 1 by mathematical convention. This is because there is exactly one way to arrange zero items: do nothing.
Factorials are used in permutations, combinations, probability calculations, Taylor series expansions, and many areas of mathematics and computer science.
Factorials grow extremely fast. 20! is already over 2 quintillion. For very large numbers, scientific notation or special big-number libraries are needed.