Factorial Calculator
Enter a non-negative integer n to compute n!. This calculator uses exact BigInt arithmetic for precise results.
Tip: for performance, this page limits input to n ≤ 5000.
What is n factorial?
The factorial of a number n, written as n!, is the product of all positive integers from 1 up to n. Factorials are one of the most common building blocks in algebra, combinatorics, probability, and computer science.
Important base values
- 0! = 1 (by definition)
- 1! = 1
- 2! = 2
- 5! = 120
- 10! = 3,628,800
How to use this factorial calculator
This page is designed to be quick and simple:
- Enter a whole number n (0, 1, 2, 3, ...).
- Click Calculate n!.
- Read the exact factorial result and summary stats (digits, trailing zeros, scientific notation).
- Use Clear to reset and try another value.
If you type a negative number or decimal value, the calculator shows an error message because the basic factorial function is defined for non-negative integers only.
Why factorials grow so fast
Factorials scale extremely quickly. Every time n increases by 1, the previous result is multiplied by a larger number. For example, 20! already has 19 digits, and 100! has 158 digits. This explosive growth is why factorials are often shown in scientific notation for large n.
This calculator computes exact values using JavaScript BigInt, which avoids rounding errors found in normal floating-point math for huge integers.
Where factorials are used
1) Counting arrangements (permutations)
If you want to know how many ways to arrange n unique objects, the answer is n!. For example, 6 people can stand in a line in 6! = 720 different ways.
2) Combinations and binomial coefficients
The combination formula uses factorials directly:
This appears in probability, statistics, and discrete mathematics whenever order does not matter.
3) Probability distributions
Factorials appear in the binomial, Poisson, and hypergeometric distributions. If you're calculating likelihoods or event counts, you're likely using factorials somewhere in the formula.
4) Series expansions in calculus
Power series such as ex, sin(x), and cos(x) include terms divided by n!. Factorials help control the size of terms, making the series converge.
Common mistakes and quick fixes
- Using decimals: 5.5! is not part of the basic integer factorial definition. (That belongs to the Gamma function.)
- Using negative integers: standard factorial is undefined for -1, -2, etc.
- Expecting small outputs: factorial values become huge very quickly, even for moderate n.
- Forgetting 0!: remember that 0! is defined as 1, not 0.
FAQ
Why is 0! equal to 1?
It keeps formulas consistent, especially in combinatorics and algebra. For example, in combinations, C(n, 0) should always equal 1. This only works cleanly when 0! = 1.
Can this calculator handle very large n?
Yes, up to 5000 in this demo. Results are exact, but very large outputs are abbreviated for readability. You still get meaningful metadata such as digit count and trailing zeros.
What are trailing zeros in n!?
Trailing zeros come from factors of 10, which are built from 2 × 5. Since factorials have many more 2s than 5s, the number of trailing zeros depends on how many factors of 5 appear in n!.