Factorial Calculator
Calculate factorial (n!) and double factorial (n!!). Useful for permutations, combinations, and mathematical calculations.
Factorial multiplies every whole number from n down to 1, and this calculator switches between two entirely different methods depending on how large n is. Up through 170, it multiplies the numbers together directly in a loop; above 170, the loop is abandoned in favor of Stirling's approximation, a formula built from square roots and powers of e that estimates enormous factorials without ever multiplying the full chain of integers, trading exactness for a result that stays computable at any size. That 170 cutoff is an overflow boundary, not an accuracy one: 171! is too large for a standard floating-point number to represent at all and would come back as Infinity, so direct multiplication stops just short of that. The loop's results stop being mathematically exact numbers well before then, though — 18! is 6,402,373,705,728,000, still inside the range where every integer is represented exactly, but 19! already exceeds that range at over 121 quadrillion, so from n = 19 onward the direct-multiplication loop is still running and still avoiding overflow, but the specific integer it returns can no longer be trusted to be exactly correct down to the last digit. The Double Factorial output multiplies only every other integer down from n — for the default value of 5, that is 5 times 3 times 1, giving 15, not the 120 that ordinary factorial produces from the same input — and it uses the same direct-multiplication approach regardless of how large n gets, since it was not given the Stirling fallback the way ordinary factorial was. Negative numbers are converted to their positive equivalent before either calculation runs, via an absolute-value step, so entering negative 5 quietly returns the same answer as entering 5 rather than reporting an error or leaving factorial mathematically undefined the way it technically is for negative integers.
Inputs
Results
Factorial (n!)
120
How to Use This Calculator
- Enter a non-negative integer n in the Number field; n! is defined as 1 × 2 × 3 × … × n, with 0! = 1.
- Factorial grows extremely fast — n = 20 gives 2.4 × 10¹⁸, so very large inputs return scientific notation.
- Double Factorial (n!!) multiplies only every other integer: for odd n, n!! = n × (n−2) × … × 3 × 1.
- Factorials are the foundation of permutations (P(n,r) = n!/(n−r)!) and combinations (C(n,r) = n!/(r!(n−r)!)).
- Non-negative integers only — negative inputs and decimals are not supported by standard factorial.
How the result changes with Number (n)
| Number (n) | Factorial (n!) |
|---|---|
| 2 | 2 |
| 7 | 5,040 |
| 13 | 6,227,020,800 |
| 18 | 6,402,373,705,728,000 |
What each input means
- Number (n)
- Enter a non-negative integer
How this is calculated
Formula
n! = n × (n-1) × (n-2) × ... × 2 × 1Worked example, using the default values
- Identify Input ParametersNumber (n) = 5 = 1 input(s) provided
- Calculate FactorialFactorial120 = 120
- Calculate Double FactorialDouble Factorial15 = 15
Engine last updated .
Frequently Asked Questions
Why does the calculator switch methods above 170?
170! is the largest factorial a standard floating-point number can represent at all — 171! overflows to Infinity. Past that point the calculator switches to Stirling's approximation, a formula involving square roots and powers of e, which estimates the size of the result instead of multiplying every integer in the chain. Note that results stop being exact integers well before 170 — 18! is the last exact one, and 19! already isn't — though they keep growing without overflowing all the way up to that boundary.
Why is the Double Factorial for 5 equal to 15, not 120?
Double factorial only multiplies every other integer counting down from n, so 5!! is 5 times 3 times 1, which is 15. Ordinary factorial multiplies every integer without skipping, so 5! includes 4 and 2 as well and reaches 120 instead.
What happens if I enter a negative number?
The calculator takes the absolute value first, so entering negative 5 returns exactly the same result as entering 5. Factorial is technically undefined for negative integers, but this tool sidesteps that by converting the sign away before any multiplication begins.
Does Double Factorial also switch to an approximation for large n?
No. Unlike ordinary factorial, the Double Factorial output always multiplies the integers directly in a loop, regardless of how large n is, since it was not given the same Stirling's-approximation fallback that ordinary factorial switches to above 170.
Related Calculators
The questions that sit next to this one — chosen by subject, including calculators filed under a different category.
Probability Calculator
Calculate probability of single events, combined events (AND/OR), permutations, and combinations.
Math & StatisticsScientific Calculator
Scientific calculator with multiple modes and expression input
Discrete MathematicsPermutations & Combinations Calculator
Calculate permutations and combinations with or without repetition for any n and r values.
Math & StatisticsPermutation & Combination Calculator
Calculate permutations and combinations. Essential for probability, statistics, and counting problems.
More in Math & Statistics.