Factorial Calculator
Calculate factorial (n!) of a number
What Is the Factorial Calculator?
The factorial of a non-negative integer n, written n!, is the product of all positive integers less than or equal to n. It's one of the most fundamental operations in combinatorics, showing up anywhere you need to count how many ways a set of items can be arranged, ordered, or selected — from card-shuffling probabilities to scheduling problems to the coefficients in a binomial expansion.
Factorials were first used systematically in the 1600s-1700s as mathematicians worked out permutation and combination counting, and the "!" notation itself was introduced in the early 1800s specifically because factorial values grow so fast that a compact symbol was more practical than writing out the full product every time. That rapid growth is still the single most distinctive property of the factorial function today — it outpaces polynomial and even exponential growth once n gets reasonably large.
This calculator computes exact factorial values instantly, handles the 0! = 1 special case correctly, and flags inputs where JavaScript's floating-point precision can no longer represent the result accurately. For related counting problems, see the Permutation Calculator and Combination Calculator, both of which are built directly on top of the factorial function.
Factorial Calculator Formula
n! = n × (n−1) × (n−2) × ... × 2 × 1
How Is the Factorial Calculator Calculated?
Factorial counts the number of ways to arrange n distinct items in a sequence: there are n choices for the first position, (n−1) remaining choices for the second, and so on down to 1 — multiplying all these choices together gives n!. By convention, 0! is defined as 1, representing the single way to arrange zero items (doing nothing).
For very large n, computing the exact product term by term becomes impractical, so mathematicians and statisticians often use Stirling's approximation instead: n! ≈ √(2πn) · (n/e)ⁿ, which estimates the factorial's size (and even its number of digits) without multiplying out every term. This calculator always computes the exact value rather than an approximation, up to the limit where JavaScript's number precision remains reliable.
Factorial Calculator Example
5! = 5 × 4 × 3 × 2 × 1 = 120.
7! = 7 × 6 × 5 × 4 × 3 × 2 × 1 = 5,040 — notice how much faster the result grows even two steps later.
0! = 1, by the standard mathematical convention rather than by multiplying anything out.
How to Use the Factorial Calculator
Step 1
Enter a non-negative whole number.
Step 2
Click Calculate Factorial.
Step 3
View the exact factorial result.
Step 4
Try a few nearby values (like n and n+1) to see how quickly the result grows.
Step 5
Use the result with the Permutation or Combination calculator if you're solving a counting problem.
Benefits
- Instantly computes exact factorial values without manual multiplication.
- Correctly handles the special case of 0! = 1.
- Flags inputs beyond safe precision limits instead of silently returning a wrong answer.
- Useful as a quick building block when working through permutation or combination problems by hand.
- Free, runs entirely in your browser, and produces a shareable branded image of your result.
Common Factorial Calculator Scenarios
Scenario 1
Calculating permutations and combinations for probability problems.
Scenario 2
Counting the number of ways to arrange a set of items, like seating charts or race finishes.
Scenario 3
Evaluating terms in Taylor series or other calculus expansions.
Scenario 4
Checking homework or exam answers that involve factorial notation.
Scenario 5
Estimating how large a search space or brute-force problem is (e.g. "how many ways can 8 items be ordered?").
Understanding Your Result
The result is the exact number of ways to arrange n distinct items in order. Factorials grow extremely quickly — even relatively small values of n produce enormous results, since each additional term multiplies the running product by a larger and larger number.
For context: 10! is already 3,628,800 — more than three and a half million — and 20! exceeds 2.4 quintillion (2,432,902,008,176,640,000), a number with 19 digits. By the time n reaches 170, the result has over 300 digits, which is right at the edge of what standard floating-point numbers can represent precisely.
Tips
- Remember that 0! = 1 by definition, not 0.
- Factorials grow faster than exponential functions, so results become huge very quickly.
- Use factorials together with the Permutation or Combination calculators for counting problems.
- If you need the number of digits in a huge factorial rather than the exact value, Stirling's approximation is faster than exact computation.
- Double-check whether a problem actually needs a "double factorial" (n!!, which skips every other number) — it's a different, related operation that this calculator does not compute.
Common Mistakes
- Assuming 0! equals 0 instead of the correct value, 1.
- Trying to compute the factorial of a negative number, which is undefined.
- Expecting precise results beyond 170!, where JavaScript's number precision breaks down.
- Confusing factorial (n!) with double factorial (n!!), which only multiplies every other integer.
- Assuming factorial and exponential growth (like 2ⁿ) are roughly the same size — factorial overtakes any fixed exponential base as n grows.
Frequently Asked Questions
What is 0!?
0! is defined as 1 by mathematical convention, which keeps formulas involving factorials (like permutations and combinations) consistent, since it represents the single way to arrange zero items.
Why is there a limit of 170?
Factorials grow extremely fast — 171! exceeds the maximum value JavaScript can represent precisely as a floating-point number, so results beyond 170! would silently lose accuracy or overflow to Infinity.
Where are factorials used?
Factorials are used in permutations, combinations, probability theory, and series expansions in calculus, as well as in statistics formulas like the binomial and Poisson distributions.
Can I calculate the factorial of a decimal number?
This calculator only supports non-negative whole numbers — factorials of non-integers require the more advanced Gamma function, which extends the factorial concept to real and complex numbers.
How fast do factorials grow?
Very fast — 10! is already 3,628,800, and 20! exceeds 2.4 quintillion, illustrating how quickly factorial values expand as n increases by even a small amount.
What is the factorial of a negative number?
Factorials are only defined for non-negative integers (0, 1, 2, ...) — the factorial of a negative number is undefined in the standard definition used by this calculator.
How is factorial related to permutations and combinations?
Both permutation (nPr = n!/(n−r)!) and combination (nCr = n!/(r!(n−r)!)) formulas are built directly from factorials, since they count arrangements or selections from a set of n items.
Why does factorial grow so much faster than exponential functions?
Each additional term in the factorial product is itself increasing, while exponential growth multiplies by the same fixed base each time — this compounding growth of the multiplier is why factorials eventually outpace any fixed exponential.
What's the factorial of 1?
1! equals 1, since it's simply the product of all positive integers up to 1.
Can I share my factorial result as an image?
Yes — tap Share and, on supported devices, your result is shared as a branded image card, not just a text link.
What is a double factorial, and is it the same as regular factorial?
No — double factorial (written n!!) multiplies only every other integer down from n (for example, 5!! = 5 × 3 × 1 = 15), while regular factorial multiplies every integer down from n. This calculator computes only the regular factorial.
What is Stirling's approximation, and does this calculator use it?
Stirling's approximation (n! ≈ √(2πn) · (n/e)ⁿ) estimates factorial size for very large n without full multiplication. This calculator always computes the exact value rather than an approximation, within the precision limits noted above.
Why does 13! already have 10 digits?
Because each term in the product is larger than the last, factorial growth accelerates — 13! equals 6,227,020,800, and by n = 25 the result already has 26 digits.
Is there a faster way to compute n! by hand than multiplying every term?
Not exactly faster, but grouping terms (like multiplying pairs that are easy to combine) can make manual calculation less error-prone; for anything beyond small n, a calculator like this one avoids the risk of an arithmetic slip.
References
Important Information
Results are exact for n up to 170; beyond that, JavaScript number precision is insufficient.
Last updated: July 25, 2026