Factorial Calculator
Enter a non-negative integer n to compute n! (n factorial), the product of every positive integer from 1 up to n. Factorials grow extraordinarily fast — 20! exceeds 2.4 quintillion — and are foundational to combinatorics, probability, and analysis. This calculator supports values from 0 to 20.
Advertisement
Calculator
See your Factorial Calculator results
Enter your email to unlock results — free forever.
No spam, ever. Unsubscribe at any time.
Advertisement
Formula
n! = n × (n−1) × (n−2) × … × 2 × 1
The factorial of a non-negative integer n, written n!, is the product of all positive integers from 1 through n. By convention, 0! = 1 (the empty product). So 5! = 5 × 4 × 3 × 2 × 1 = 120. Factorials grow faster than any polynomial or exponential function with a fixed base. Stirling's approximation gives n! ≈ √(2πn) × (n/e)ⁿ for large n, which is accurate to within 1% for n ≥ 10.
How to use the Factorial Calculator
- 1
Enter your n (integer 0–20)
- 2
Read your results instantly
Results update in real time as you type.
Advertisement
What factorials represent
The factorial n! counts the number of ways to arrange n distinct objects in a sequence — called permutations. If you have five books on a shelf, there are 5! = 120 different orders you could arrange them. This is because the first position can hold any of 5 books, the second any of the remaining 4, and so on: 5 × 4 × 3 × 2 × 1 = 120.
Factorials also appear in combinations: the number of ways to choose r items from n without regard to order is n! / (r! × (n−r)!). This formula, called the binomial coefficient or 'n choose r,' is written C(n, r) and relies entirely on factorials.
Beyond counting, factorials appear in Taylor series expansions: the series for eˣ is 1 + x + x²/2! + x³/3! + …, where each term is divided by a factorial. The same structure appears in the series for sin x, cos x, and many other fundamental functions.
Why 0! equals 1
The assignment 0! = 1 seems arbitrary at first but is mathematically necessary for consistency. The most intuitive justification: 0! counts the number of ways to arrange zero objects. There is exactly one way to do nothing — the empty arrangement — so 0! = 1.
A more algebraic justification uses the recurrence relation: n! = n × (n−1)!. If we set n = 1, we get 1! = 1 × 0!, so 0! must equal 1! / 1 = 1. Without this definition, combinatorial formulas like C(n, 0) = n!/(0!×n!) would be undefined, but we know C(n, 0) = 1 (there is exactly one way to choose nothing from n items).
The gamma function extends factorials to non-integers: Γ(n) = (n−1)! for positive integers, and Γ(½) = √π. This generalization is used in statistics, physics, and complex analysis.
Advertisement
The explosive growth of factorials
Factorials grow faster than almost anything else commonly encountered in mathematics — faster than exponential functions like 2ⁿ or 10ⁿ, and far faster than polynomials. At n = 5, n! = 120. At n = 10, n! = 3,628,800. At n = 20, n! = 2,432,902,008,176,640,000 — about 2.4 quintillion.
This explosive growth has practical consequences. In combinatorial optimization problems like the traveling salesman problem, the number of possible routes through n cities is (n−1)!/2, which makes brute-force search infeasible even for n = 20. This is why efficient algorithms and heuristics are essential in computer science.
In probability, this growth means the chance of a specific random arrangement occurring by chance drops rapidly: the chance that 10 shuffled cards appear in a specific order is 1/10! ≈ 1 in 3.6 million.
Tips & Insights
Use the recurrence for hand calculation
To compute a factorial by hand, use the fact that n! = n × (n−1)!. Start from a known value: 5! = 120, so 6! = 6 × 120 = 720, 7! = 7 × 720 = 5040, and so on. You only need to remember one base value and multiply up.
Simplify before multiplying in formulas
When computing expressions like n!/k!, cancel common factors before multiplying. For 10!/7!, cancel 7! from both: 10!/7! = 10 × 9 × 8 = 720. Writing out all digits and then dividing is both slow and error-prone.
Factorial vs. exponentiation
Students sometimes confuse n! with nⁿ. They are very different: 5! = 120 but 5⁵ = 3125. For small n, nⁿ is larger, but factorials eventually overtake any fixed exponential. By n = 25, n! far exceeds 2ⁿ.
Worked Examples
Counting seating arrangements
6! = 720. There are 720 different ways to seat 6 people at 6 chairs in a row.
Password permutations
10! = 3,628,800. If a 10-character password uses each digit 0–9 exactly once, there are over 3.6 million possible combinations.
Advertisement
Frequently Asked Questions
Why is 0! equal to 1?
By convention and mathematical consistency. There is exactly one way to arrange zero objects (the empty arrangement), and the recurrence relation n! = n × (n−1)! requires 0! = 1 so that 1! = 1 × 0! = 1 holds correctly.
What is the largest factorial this calculator handles?
This calculator handles n from 0 to 20. At n = 20, the result is approximately 2.43 × 10¹⁸. Larger factorials exceed JavaScript's safe integer range (2⁵³ − 1) and require arbitrary-precision libraries for exact results.
How are factorials related to combinations and permutations?
Permutations P(n, r) = n!/(n−r)! count ordered selections. Combinations C(n, r) = n!/(r!(n−r)!) count unordered selections. Both are built entirely from factorials.
Can factorials be computed for fractions?
Yes, using the gamma function: Γ(n+1) = n! for positive integers, and Γ(½) = √π. So (½)! = Γ(3/2) = √π/2 ≈ 0.8862. The gamma function is a smooth curve that passes through all the integer factorial values.
How fast do factorials grow?
Very fast — superexponentially. Stirling's approximation gives n! ≈ √(2πn)(n/e)ⁿ. Practically: 10! ≈ 3.6 million, 15! ≈ 1.3 trillion, 20! ≈ 2.4 quintillion. This growth makes brute-force combinatorial algorithms infeasible for even moderate n.
Advertisement