Factorial Calculator
Calculate exact factorials up to 25,000!, double factorials and subfactorials, with digit count, trailing zeros and Stirling’s estimate.
Tool guide
What this tool does
The Factorial Calculator computes n! exactly with big-integer arithmetic, printing every digit of numbers as large as 25,000! (over 99,000 digits). It also handles double factorials n!!, derangement counts !n and non-integer factorials through the gamma function.
The factorial n! is the product of all whole numbers from 1 to n, and it counts the number of ways to arrange n distinct objects. It grows faster than any exponential: 10! is 3,628,800, 21! already exceeds the range of a signed 64-bit integer, and 70! is larger than a googol. Ordinary calculators therefore show factorials above about 170 as overflow or a rounded figure.
This tool multiplies with arbitrary-precision integers using binary splitting, which pairs factors so the multiplications stay balanced and fast. Up to 25,000! the exact value is produced with every digit; above that, the digit count and leading digits are derived from logarithms. It also reports trailing zeros using Legendre’s formula, Stirling’s approximation √(2πn)(n/e)^n, double factorials, subfactorials (derangements) and, for decimal inputs, Γ(x + 1) via the Lanczos approximation.
How to use Factorial Calculator
- Enter n. Whole numbers give exact results; decimals such as 0.5 use the gamma function.
- Choose the type: Factorial n!, Double factorial n!! or Subfactorial !n.
- Read the highlighted value. Long results show the first and last digits with the total digit count.
- Copy the Full value card to get every digit, or download the table of factorials for small n.
- Compare the Stirling approximation with the exact value to see how accurate it is for your n.
Tips for better results
- Trailing zeros come from pairs of 2 and 5; because 2s are plentiful you only count 5s: 100! ends in 20 + 4 = 24 zeros.
- Combinations n!/(k!(n−k)!) are easier in the Permutation and Combination Calculator, which avoids huge intermediates.
- The probability that a random shuffle leaves no item in place, !n / n!, quickly approaches 1/e ≈ 36.79%.
Common use cases
- Counting arrangements, seatings and orderings in probability problems.
- Checking exact big-integer results when testing software or puzzles.
- Estimating the size of search spaces in computer science.
- Exploring the gamma function, for example 0.5! = √π / 2.
Common mistakes to avoid
- Thinking 0! is 0. By definition 0! = 1, the number of ways to arrange nothing.
- Reading n!! as (n!)!. A double factorial multiplies every second number: 7!! = 7 × 5 × 3 × 1 = 105.
- Expecting a factorial of a negative integer; the gamma function has poles there, so it is undefined.
Frequently asked questions
Why is 0! equal to 1?
There is exactly one way to arrange zero objects, and defining 0! = 1 keeps formulas such as n! = n × (n − 1)! and the combination formula consistent.
How many digits does 1000! have?
1000! has 2,568 digits and ends in 249 zeros. The calculator prints all of them and lets you copy the full value.
How are trailing zeros counted?
Legendre’s formula counts the factors of 5 in n!: ⌊n/5⌋ + ⌊n/25⌋ + ⌊n/125⌋ + …. Each 5 pairs with a 2 to make a factor of 10.
What is a subfactorial?
The subfactorial !n counts derangements, the arrangements where no item stays in its original position. For example !4 = 9, and in general !n is n!/e rounded to the nearest integer.
Feedback & suggestions
Help us improve Factorial Calculator. We read every message.