Factorial Calculator
The factorial of n, written n!, is the product of every whole number from 1 up to n. It counts how many ways you can arrange n items and is the building block of permutations and combinations.
Your numbers
Result
- Number of digits
- 3
| Step | Detail |
|---|---|
| 5! | 5 x 4 x 3 x 2 x 1 |
| Result | 120 |
| Number of digits | 3 |
How factorials work
n! multiplies every whole number from 1 up to n: 5! = 5 × 4 × 3 × 2 × 1 = 120. The definition is recursive — n! = n × (n−1)! — which is why factorials are so easy to compute and so easy to reason about.
The base case is the part that surprises people: 0! = 1, not 0. That is not an arbitrary patch. There is exactly one way to arrange an empty collection (do nothing), and the recursion only stays consistent if 1! = 1 × 0! comes out to 1. Every formula built on factorials — binomial coefficients above all — breaks if you set 0! to anything else.
In the ordinary sense the factorial is defined only for non-negative whole numbers. Ask for the factorial of −3 or of 2.5 and the product has no last term to stop at.
Why the numbers explode
Factorial growth is not exponential — it is faster. An exponential like 2ⁿ multiplies by the same factor at every step; a factorial multiplies by a larger factor at every step, and that difference compounds violently.
5! = 120. 10! = 3,628,800. 20! = 2,432,902,008,176,640,000 — over two quintillion. 170! runs to 307 digits.
Stirling's approximation is the standard way to describe the shape of that curve without computing it: n! grows roughly like (n ÷ e)ⁿ × √(2πn). The term to read is nⁿ. Each extra unit of n does not add to the answer, it re-multiplies it.
This is also why brute force collapses in combinatorics. Checking every ordering of just 20 items at a billion per second would take roughly 77 years. The arithmetic is trivial; the enumeration is impossible.
Where factorials show up
Factorials count arrangements, and that one fact carries them across mathematics.
The number of ways to put n distinct items in order is exactly n! — five books on a shelf can be arranged 120 ways. From there come permutations, nPr = n! ÷ (n−r)!, and combinations, nCr = n! ÷ (r! × (n−r)!), where the extra r! divides out the orderings you did not want counted.
Those same combination counts are the coefficients of the binomial theorem, so factorials sit underneath every expansion of (a + b)ⁿ and under every row of Pascal's triangle.
In calculus they turn up as denominators. The Taylor series for eˣ is 1 + x + x²/2! + x³/3! + …, and the factorial on the bottom is exactly what makes the terms shrink fast enough for the series to converge. Probability inherits them wholesale — the Poisson distribution carries a k! in its denominator for the same combinatorial reason.
Beyond whole numbers: the gamma function
"What is 2.5 factorial?" does have an answer, just not from the product definition. The factorial is extended to real and complex arguments by the gamma function, written Γ, which matches the factorial at the whole numbers and interpolates smoothly in between.
The catch is the offset in the notation, and it trips people up constantly: Γ(n) = (n−1)!, so Γ(5) = 4! = 24, not 120.
Gamma is what a scientific library actually evaluates when you ask for a non-integer factorial, and it is the reason half-integer cases come back with a √π in them. This calculator does not go there — it takes whole numbers and returns the exact product.
Exact results, and where floating point gives up
Factorials are the shortest route to an arithmetic overflow, so how a tool stores the number matters more than usual.
A standard double-precision float — the default number type in most languages, JavaScript included — represents every whole number exactly only up to 2⁵³, about 9.0 quadrillion. Factorials cross that line fast: 23! is the first factorial a double cannot hold exactly, and past it the trailing digits are wrong while the display still looks confident.
The hard ceiling comes soon after. A double tops out near 1.8 × 10³⁰⁸, so 170! is the last one that fits at all and 171! is simply Infinity. That is where the input limit on this page comes from.
This calculator uses big-integer arithmetic instead, so every digit shown is exact all the way to 170!. When the full expansion is more than you need, the digit count beside the result is usually the more useful number.
Frequently asked questions
Sources
Embed this calculator
Copy the code and paste it into your site or blog. Credit with a link back to Contania is included, and the height adjusts itself.
<iframe src="https://contania.app/embed/math/factorial" title="Factorial Calculator (n!)" width="100%" height="720" loading="lazy" style="border:1px solid #e5e0d8;border-radius:12px;max-width:640px"></iframe>
<script>window.addEventListener("message",function(e){if(e.data&&e.data.type==="contania:embed-height"){var f=document.querySelector('iframe[src="https://contania.app/embed/math/factorial"]');if(f){f.style.height=e.data.height+"px"}}});</script>Related calculators
Combinations
Calculate combinations (nCr) and permutations (nPr). Enter n and r to find how many ways to choose or arrange items — order matters for permutations, not for combinations.
CalculateProbability
Calculate the probability of an event from the favorable and possible outcomes. See the result as a percentage, a decimal and a fraction.
CalculateExponent
Raise any number to a power. Enter a base and an exponent — including negative and fractional exponents — to get the result.
CalculateFractions
Add, subtract, multiply and divide fractions, with the result already simplified and shown as a decimal. Enter the numerators and denominators.
Calculate