Factorial Calculator

n! (factorial)—
Number of digits—
Input number (n)—

How Factorial Calculator is calculated: n! = n × (n − 1) × (n − 2) × … × 2 × 1, and 0! = 1

What is a factorial?

A factorial is the product of a whole number and every whole number below it. The factorial of 5, written 5!, is 5 × 4 × 3 × 2 × 1 = 120. The factorial of 3 is 3 × 2 × 1 = 6, and the factorial of 1 is simply 1. Factorials grow astonishingly fast: 10! is already 3,628,800, and 20! is 2,432,902,008,176,640,000.

The one special case is zero. By definition, 0! = 1. That looks odd at first — multiplying nothing together and getting 1 — but it is the only value that keeps the maths consistent. There is exactly one way to arrange zero objects: the empty arrangement. Every formula that uses factorials, from combinations to probability, depends on 0! being 1.

This calculator takes a number from 0 to 170 and returns its factorial, the number of digits in the answer, and the input itself. The result updates as you type. Nothing is uploaded, and there is no sign-up.

How a factorial calculator works

The method is a single multiplication chain. Start at the number and multiply downward: 5! = 5 × 4 × 3 × 2 × 1 = 120. Each step multiplies the running total by the next smaller number, so the total grows by a larger jump each time — that is why factorials explode in size so quickly.

The calculator also counts the digits of the answer, which is often the more useful number. 5! has 3 digits, 10! has 7 digits, and 20! has 19 digits. The digit count comes from the logarithm of the factorial: the number of digits is the whole part of log₁₀(n!) plus one. For 170!, the largest factorial this calculator handles, the answer has 307 digits.

Decimals are not allowed — factorials are defined for whole numbers only. If you type 5.7, the calculator rounds down to 5 and computes 5! = 120. Negative numbers are treated as 0, giving 0! = 1, rather than an error.

A handy shortcut exists for factorials inside bigger calculations: n! = n × (n−1)!, so 6! is just 6 × 120 = 720 once you know 5!. Working upward from a known factorial saves repeated multiplication, and it is how most combination formulas are evaluated by hand.

Why the cap is 170

The calculator stops at 170 because JavaScript numbers stop working beyond it. 170! is about 7.26 × 10³⁰⁶, which fits inside the largest number JavaScript can hold, roughly 1.8 × 10³⁰⁸. But 171! would need about 1.24 × 10³⁰⁹, which is bigger than that limit — the result overflows to Infinity, which is not a factorial at all.

This is a limit of the number format, not of the maths. Factorials keep growing forever: 200!, 500! and 1000! are all perfectly good numbers in mathematics, with 1000! having 2,568 digits. Computing them needs special big-number software, and a browser calculator that promises an exact integer answer cannot fake it with ordinary floating-point numbers.

If you need a factorial above 170, the digit count is usually what matters, and Stirling's approximation gives it: the number of digits in n! is close to n × log₁₀(n) − 0.4343 × n. For most school and exam work, though, 170 is far beyond anything required — factorials above 20 already exceed the number of seconds since the Big Bang.

A worked example: 5!, 0!, 10! and 20!

Start with the default: 5! = 5 × 4 × 3 × 2 × 1 = 120, and 120 has 3 digits. That is the factorial every student meets first, and it is small enough to check by hand in seconds.

Now the special case: 0! = 1, with 1 digit. No multiplication happens at all, and the answer is 1 by definition. If your calculation ever needs 0!, the calculator gives 1 without complaint — and any formula that divides by 0! is really just dividing by 1.

Next, 10! = 3,628,800, which has 7 digits. The jump from 5! to 10! is a factor of 30,240 — multiplying by 6, 7, 8, 9 and 10 in turn. And 20! = 2,432,902,008,176,640,000, with 19 digits. The calculator prints very large factorials in exponent form, like 7.26e+306 for 170!, because the full number would not fit on the screen.

One more check worth doing by hand is 3! = 6 and 4! = 24. The step from 3! to 4! multiplies by 4, and from 4! to 5! multiplies by 5 — each factorial is the previous one times the new number. If a factorial ever looks wrong, divide it by the previous factorial and confirm the answer is the number itself.

Where factorials actually get used

Permutations are the home turf of factorials. The number of ways to arrange 5 different books on a shelf is 5! = 120, because there are 5 choices for the first spot, 4 for the second, 3 for the third, 2 for the fourth and 1 for the last. Any question that starts with in how many orders can these be arranged is a factorial question.

Combinations use factorials too. Choosing 3 people out of 10 is 10! ÷ (3! × 7!) = 120, and the formula only works because 0! = 1 keeps the edge cases — choosing all 10, or choosing none — from breaking. Lottery odds, card hands and team selections are all factorial calculations underneath.

Probability theory is built on factorials. The chance of a particular poker hand, the number of possible passwords of a given length, and the number of ways a deck of cards can be shuffled — 52!, a number with 68 digits — all come from the same multiplication chain. A probability calculator handles the final odds, but the counting underneath is factorials.

Computer science leans on factorials for sorting and searching. The number of possible orderings of n items is n!, which is why sorting a list of 10 items can be done quickly but sorting a list of 100 items by trying every order is impossible — 100! has 158 digits, far more than the number of atoms in the observable universe.

Factorial calculator vs probability calculator

A factorial counts arrangements; a probability calculator turns those counts into chances. 5! = 120 tells you there are 120 ways to order five books, while the probability that a random order is the one you want is 1 ÷ 120, about 0.83%. The factorial is the counting step, and the probability is the counting step divided by the total.

Use the factorial calculator when the question is how many ways — arrangements, selections, orderings. Use the probability calculator when the question is how likely — the chance of an event, the odds of a draw, the risk of a failure. The two tools sit next to each other in most textbooks for exactly this reason.

A scientific calculator also has a factorial key, and it is the right tool when a factorial is one step inside a longer calculation. This page is the right tool when the factorial itself is the answer you need, with the digit count alongside it. Factorials are the building blocks of counting: a permutation calculator uses them to count ordered arrangements, where the order of the items matters.

Common factorial mistakes

The most common mistake is thinking 0! is 0. It is 1, by definition, and every combinations formula depends on it. Choosing 0 items from 5 is 5! ÷ (0! × 5!) = 1 — there is exactly one way to choose nothing — and that only works because 0! = 1.

The second mistake is adding instead of multiplying. 5! is not 5 + 4 + 3 + 2 + 1 = 15; it is 5 × 4 × 3 × 2 × 1 = 120. Addition grows slowly, multiplication explodes, and confusing the two understates the answer by orders of magnitude.

The third mistake is squaring instead of factorialising. 5! is not 5² = 25, and it is not 5⁵ = 3,125 either. Factorials, powers and squares are three different operations, and the exponent calculator handles powers when that is what the problem actually asks for.

The fourth mistake is forgetting how fast factorials grow and trusting a rounded answer. 20! is already 19 digits long, and the last digits of large factorials are always zeros — 20! ends in four zeros — because the multiplication picks up factors of 2 and 5 along the way. Quote the digit count when the full number is too long to be useful. A fifth mistake is treating n! as roughly n raised to n. It is much smaller: 5! is 120 while 5 to the power 5 is 3,125, and the gap grows with n. Stirling's formula says n! is close to (n/e) to the power n times the square root of 2πn, which is the estimate to use when the exact factorial is out of reach.

How to use this factorial calculator

Type a whole number from 0 to 170 into the box. The factorial, the number of digits, and the input number update live as you type. Decimals are rounded down to the nearest whole number, and anything above 170 is capped at 170, because 171! overflows JavaScript numbers to Infinity.

Try 5 first to check the tool: 5! = 120 with 3 digits. Then try 0 to see the special case, 10 to see the jump to seven digits, and 20 to see a 19-digit answer. The digit count row is the quickest way to feel how fast factorials grow.

Everything runs in your browser. No account, no upload, no data sent anywhere — your numbers never leave your device. Use it for permutations, combinations, and counting problems, and pair it with the GCD calculator whenever a problem mixes counting with dividing numbers into equal groups.

Frequently Asked Questions

5! is 120. It is 5 × 4 × 3 × 2 × 1 = 120, and 120 has 3 digits. That is the factorial most students meet first, and it is small enough to check by hand.

0! is 1, by definition. There is exactly one way to arrange zero objects — the empty arrangement — and every combinations formula depends on 0! being 1. Choosing 0 items from 5 is 5! ÷ (0! × 5!) = 1.

Because 170! is about 7.26 × 10³⁰⁶, which fits inside the largest number JavaScript can hold, roughly 1.8 × 10³⁰⁸. 171! would need about 1.24 × 10³⁰⁹, which overflows to Infinity. Factorials above 170 need special big-number software.

20! is 2,432,902,008,176,640,000, which has 19 digits. The digit count comes from the logarithm: the number of digits is the whole part of log₁₀(20!) plus one.

More free tools

More calculators and utilities from Sortrun — free, no sign-up.