What this calculator does
Find the exact factorial of any whole number, along with its size and how many zeros it ends in. The factorial of a whole number n, written n! and said "n factorial", multiplies every whole number from 1 up to n. So 5! = 5 × 4 × 3 × 2 × 1 = 120. Factorials count arrangements: n different objects can be lined up in n! different orders. They turn up all over probability, counting problems and calculus. You'll meet them inside permutations (ordered arrangements), combinations (unordered groups), the binomial theorem and Taylor series.
Factorials grow faster than any exponential, meaning faster than repeatedly multiplying by the same number. 10! is about 3.6 million, 20! already passes 2 quintillion, and 100! has 158 digits. This calculator works with exact whole numbers of any length, so every digit is correct for n up to 3,000. It shows the value in scientific notation (a number times a power of 10). It lists the exact digits when there are no more than 1,000 of them. It also counts the digits and the zeros at the end, called trailing zeros.
Where it's used
Why this math matters outside the classroom:
- Lining up. A teacher can line up 5 students in 5! = 120 different orders.
- Shuffled cards. A standard 52-card deck can be ordered in 52! different ways, a number with 68 digits.
- Race finishes. Eight runners can cross the finish line in 8! = 40,320 possible orders, assuming no ties.
- Delivery routes. A delivery driver with 6 stops has 6! = 720 possible orders in which to visit them.
- Choosing groups. Statistics students use factorials in 10! ÷ (3! × 7!) = 120 to count the ways to choose 3 people from 10.
How to use it
- Enter a whole number n from 0 to 3,000.
- Read n! at the top. Below 10^15 it appears as an ordinary number; above that, in scientific notation.
- Check the exact digits, the digit count and the number of trailing zeros. The working shows how the zeros are counted.
What the inputs mean
- Number (n)
- Factorials are defined for the whole numbers 0, 1, 2 and so on. Negative numbers and fractions are turned away with an explanation. For numbers that aren't whole, the standard extension is the gamma function (see the FAQ).
Formula and method
n! = n × (n − 1) × (n − 2) × … × 2 × 1 0! = 1 trailing zeros Z = ⌊n/5⌋ + ⌊n/25⌋ + ⌊n/125⌋ + … n! = Γ(n + 1)
In the formulas, n is your whole number and n! is its factorial. Z is the number of trailing zeros. The brackets ⌊ ⌋ mean "round down to a whole number", so ⌊10/5⌋ = 2. Γ is the gamma function, explained in the FAQ.
The definition is just a long multiplication. It also follows the rule n! = n × (n − 1)!, so each factorial is the one before it times n. Running that rule backwards from 1! = 1 gives 0! = 1. That value makes sense for counting too: there is exactly one way to arrange zero objects.
Each trailing zero comes from a factor of 10, and 10 = 2 × 5. Between 1 and n, multiples of 2 are far more common than multiples of 5. So the number of 5s decides how many zeros there are. Every multiple of 5 adds one 5, every multiple of 25 adds a second, and every multiple of 125 adds a third. This is called Legendre's formula, used here with the prime number 5.
The scientific-notation form is rounded to 10 significant digits, with halves rounded up. The exact value is worked out with whole numbers of any length, not rounded decimals. So nothing is lost, even for 3,000!, which has 9,131 digits.
Worked example
Find 10! and count its trailing zeros.
- Multiply the whole numbers from 10 down to 1: 10 × 9 × 8 × 7 × 6 × 5 × 4 × 3 × 2 × 1 = 3,628,800.
- Count the digits: the result has 7.
- Count the trailing zeros: ⌊10/5⌋ = 2. Since 25 is larger than 10, there are no more terms to add. So Z = 2.
Result: 10! = 3,628,800. It has 7 digits and ends in 2 zeros.
Understanding the result
n! is the number of ways to put n different items in order. For example, 10 books can stand on a shelf in 3,628,800 possible orders.
The digit count gives you a feel for size. 52! is the number of ways to shuffle a deck of cards, and it has 68 digits. That's far more than the number of seconds since the universe began.
The trailing-zero count tells you how many times 10 divides evenly into n!. The same idea with another prime number p tells you how many times p divides into n!.
Assumptions and limitations
- n is a whole number from 0 to 3,000. All the arithmetic is exact.
- n is capped at 3,000 to keep the page quick. The exact digits are listed only up to 1,000 digits (about 449!). Above that, you see the digit count instead.
- Inputs that are negative or not whole numbers aren't worked out. This calculator does not compute the gamma function.
Frequently asked questions
Why is 0! equal to 1?
Two reasons agree. The rule n! = n × (n − 1)! gives 1! = 1 × 0!, which only works if 0! = 1. And for counting, there is exactly one way to arrange an empty set of objects: do nothing.
What is the gamma function?
The gamma function, written Γ(x), fills in the factorial smoothly between the whole numbers, and even for complex numbers. For any whole number n, Γ(n + 1) = n!. For example, Γ(1.5) = √π / 2 ≈ 0.886, so (0.5)! is sometimes written as √π / 2. It has no value at 0 or at the negative whole numbers. That's why negative factorials are undefined.
Can I estimate a large factorial without computing it?
Yes. Stirling's approximation, n! ≈ √(2πn) × (n/e)^n, is already within 1% for n = 10. Its percentage error keeps shrinking as n grows. Here e is the math constant, about 2.718. Statistics and physics use it when only the rough size of a factorial matters.
Why does n! end in so many zeros?
Every multiple of 5 in the product pairs with one of the many even numbers to make a 10. 100! contains 20 multiples of 5. It also gets 4 extra 5s from 25, 50, 75 and 100. That makes 24 trailing zeros.
How this calculator is checked
Method: Definition of n! as a product, computed with BigInt; Legendre's formula for the exponent of 5 in n!. The calculation is covered by automated tests with known reference values and edge cases. Last updated 2026-10-18. Found a problem? Tell us.
Embed this calculator
Put this Factorial Calculator on your own website or blog for free. Paste this code where you want it to appear: