Math
Factorial Calculator
Enter a whole number to get n! exactly, even when it has thousands of digits, plus the digit count, trailing zeros, scientific notation, and how close Stirling's approximation lands.
Switch modes for the double factorial n!! or the subfactorial !n (derangements). Every value is computed with exact big-integer arithmetic, so nothing overflows or rounds.
A whole number from 0 to 10,000. Values above 170 overflow ordinary calculators but are exact here.
Try an example
Result
Value
—
- Number of digits
- —
- Trailing zeros
- —
- Scientific notation
- —
- Stirling approximation
- —
Student quick launch
Grade planning, algebra checks, and formulas students reach for most.
Study path
Use this calculator with
Follow these when you want the formula behind the answer, a short lesson, or nearby tools in the same topic.
What the factorial calculator solves
The Multiply a whole number by every whole number below it, so 4 factorial is 24. of n, written n!, is the product of every whole number from 1 up to n. It counts the number of ways to arrange n different things in a row, which is why it appears in permutations, combinations, probability, and series like e^x. This calculator returns the exact value using big-integer arithmetic, so 100! shows all 158 digits instead of an overflow error.
Modes
| Mode | Symbol | Meaning | Example |
|---|---|---|---|
| Factorial | n! | Product of 1 through n | 5! = 120 |
| Double factorial | n!! | Product of n, n - 2, n - 4, … down to 1 or 2 | 7!! = 105, 8!! = 384 |
| Subfactorial | !n | Derangements: arrangements where nothing stays in place | !4 = 9 |
Trailing zeros and digit count
Each trailing zero in n! comes from a factor of 10 = 2 × 5. Because factors of 2 are far more common than factors of 5, counting the fives is enough: zeros = ⌊n/5⌋ + ⌊n/25⌋ + ⌊n/125⌋ + …. For 100! that is 20 + 4 = 24 zeros. The digit count is ⌊log10(n!)⌋ + 1, which the calculator reads off the exact value.
Stirling's approximation
For large n, Stirling's formula estimates the factorial without multiplying everything out. The relative error shrinks like 1/(12n): about 0.8% at n = 10 and 0.08% at n = 100. The calculator prints the approximation next to the exact value so you can see how close it gets.
How to use it
- Choose Factorial, Double factorial, or Subfactorial.
- Enter a whole number n (0 or larger).
- Read the exact value in the panel; very long results show the first and last 40 digits plus Writing a number as one digit, a decimal part, and a power of ten..
- Open Show the work to see the expanded product, the trailing-zero count, and the Stirling comparison.
How to read the answer
n! is the number of ways to line up n distinct objects, so it grows extremely fast: 10! is about 3.6 million while 20! is about 2.4 quintillion. Trailing zeros tell you how many times 10 divides the result, and the digit count tells you the size at a glance. The subfactorial is always close to n!/e, which is why roughly 37% of random shuffles are derangements.
Common mistakes and edge cases
- 0! is 1, not 0. An empty product equals the multiplicative identity.
- Factorials of negative integers are undefined; decimals need the Gamma function, which this page does not compute.
- n!! is not (n!)!. The double factorial skips every other number: 6!! = 6 × 4 × 2 = 48, while (6!)! is astronomically large.
- Do not round intermediate products; a single rounded step changes every trailing digit. This calculator keeps exact big integers throughout.
- The Stirling formula is an approximation. Use it to estimate size, not for exact counts.
Worked examples
10!
Ten items can be ordered 3,628,800 ways.
Value
3,628,800
0! = 1
The empty product.
Value
1
Past floating-point overflow: 200!
375 digits, computed exactly.
Value
7.886578674 × 10^374
1000! in scientific notation
2,568 digits; the panel shows the first and last 40.
Value
4.023872601 × 10^2567
Double factorial 9!!
9 × 7 × 5 × 3 × 1
Value
945
Subfactorial !5
44 of the 120 arrangements of 5 items move every item.
Value
44
Negative input
Undefined.
Value
Error
Decimal input
Needs the Gamma function.
Value
Error
Frequently asked questions
What is 0 factorial?+
0! = 1. There is exactly one way to arrange zero objects (do nothing), and the definition n! = n × (n - 1)! only works for n = 1 if 0! = 1.
How many digits does 100! have?+
158 digits. It ends in 24 zeros, and its value is about 9.33 × 10^157. This calculator prints all 158 digits.
Why does my calculator show an error for 171!?+
171! is about 1.24 × 10^309, larger than the biggest number double-precision floating point can store. This page uses exact big-integer arithmetic instead, so there is no overflow.
How do I count trailing zeros in a factorial?+
Add ⌊n/5⌋ + ⌊n/25⌋ + ⌊n/125⌋ + … until the terms hit zero. For 25!: 5 + 1 = 6 trailing zeros.
What is a double factorial?+
n!! multiplies n by every second number below it: 7!! = 7 × 5 × 3 × 1 = 105 and 8!! = 8 × 6 × 4 × 2 = 384. It is not the factorial of a factorial.
What is a subfactorial or derangement?+
!n counts the arrangements of n items in which no item stays in its original spot. !4 = 9, and in general !n is the nearest integer to n!/e.
Can I compute the factorial of a decimal or fraction?+
Not with the product definition. The Gamma function extends factorials to real numbers via x! = Γ(x + 1); for example (1/2)! = √π/2 ≈ 0.8862.
About this calculator
- Written by
- mathcheck editorial team
- Last reviewed
- September 4, 2026
Method
- Uses the values entered by the user and stable formulas documented on the page.
Related calculators
Exponent Calculator
Calculate powers with positive, negative, and decimal exponents while showing the exponent rule used.
Scientific Notation Calculator
Convert regular numbers to scientific notation and show coefficient, exponent, and engineering notation.
Prime Factorization Calculator
Factor a positive integer into primes and show the factor tree style division steps.
Combination and Permutation Calculator
Calculate combinations and permutations for counting problems where order may or may not matter.
Binomial Probability Calculator
Calculate exact binomial probability for k successes in n independent trials.
Adding Fractions Calculator
Add up to five fractions or mixed numbers. Finds the least common denominator with prime factors, rewrites each fraction, adds, simplifies, and shows the mixed-number and decimal forms with a fraction-strip picture.
Last updated: September 4, 2026