Factorial Calculator
Compute the factorial of any non-negative integer. Enter a number n and see n! along with the complete multiplication breakdown.
Understanding Factorials
Factorials count the number of ways to arrange n distinct objects in a sequence. If you have 3 books, you can arrange them in 3! = 6 different orders. If you have 5 people in line, there are 5! = 120 possible orderings. This counting principle makes factorials essential in permutations and combinations.
The factorial function is defined recursively: n! = n ร (n-1)!. The base case is 0! = 1, which may seem strange but is necessary for formulas to work. For instance, the number of ways to choose 0 items from a set is 1 (the empty set), and this relies on 0! being 1.
Factorials grow explosively. 10! is already 3.6 million. 20! exceeds 2 quintillion. This rapid growth makes factorials useful for measuring complexity in algorithms and understanding why brute-force methods fail on large inputs. Any problem that scales with n! becomes intractable quickly.
Factorials in Combinatorics
Permutations and combinations are built on factorials. A permutation is an ordered arrangement. The number of permutations of n objects is n!. If you pick r objects from n and care about order, the formula is P(n, r) = n! / (n - r)!. For example, choosing 3 winners from 10 contestants where order matters is 10! / 7! = 720.
Combinations ignore order. The number of ways to choose r objects from n is C(n, r) = n! / (r! ร (n - r)!). Picking 3 people from 10 for a committee is 10! / (3! ร 7!) = 120. Both formulas rely on factorials to account for overcounting due to rearrangements.
Probability problems use factorials constantly. The chance of a specific shuffled deck order is 1 / 52!, an astronomically small number. Calculating lottery odds, poker hand frequencies, and event probabilities in random experiments all involve factorial-based counting. Understanding factorials unlocks a huge range of statistical and probabilistic reasoning.
Factorials Beyond Whole Numbers
While n! is defined for non-negative integers, mathematicians extend the concept using the gamma function: ฮ(n) = (n-1)! for positive integers. This function works for all complex numbers except non-positive integers. For example, ฮ(1/2) = โฯ, giving a 'factorial' for 1/2.
Stirling's approximation provides a useful estimate for large factorials: n! โ โ(2ฯn) ร (n/e)^n. This formula is accurate to within a small percentage for modest n and becomes extremely precise as n grows. It is essential in statistical mechanics, information theory, and asymptotic analysis.
In computer science, factorials measure algorithm complexity. A sorting algorithm that tries all n! permutations is O(n!) and unusable beyond tiny inputs. Recognizing factorial growth helps developers avoid infeasible approaches. This calculator handles factorials up to 170!, the limit of standard floating-point representation, giving you instant results for combinatorics, probability, and algorithm analysis.
Frequently Asked Questions
What is a factorial?
The factorial of a non-negative integer n, written n!, is the product of all positive integers from 1 to n. For example, 5! = 5 ร 4 ร 3 ร 2 ร 1 = 120.
What is 0 factorial?
By definition, 0! = 1. This convention makes many mathematical formulas work correctly, especially in combinatorics and calculus.
Why do factorials grow so quickly?
Each increase in n multiplies the previous factorial by n. So 10! = 3,628,800 and 20! = 2,432,902,008,176,640,000. Factorials exhibit super-exponential growth.
Can you compute the factorial of a negative number?
No. Factorials are only defined for non-negative integers in elementary mathematics. Extensions like the gamma function handle non-integer and complex arguments.
What is the largest factorial a computer can store?
Standard 64-bit floating point can represent up to about 170! before overflowing to infinity. For larger values, use specialized arbitrary-precision libraries.