Skip to content
Math

Factorial Calculator

Compute any factorial variant in one place. Choose from the standard factorial (n!), double factorial (n!!), subfactorial or derangement (!n), multifactorial (n(k)!), or primorial (n#). For each you get the exact value, scientific notation, the number of digits, and, for the standard factorial, the count of trailing zeros.

Your details

Standard: product 1 to n. Double: every other factor. Subfactorial: derangements. Multifactorial: every k-th factor. Primorial: product of primes up to n.
A non-negative whole number. 0! = 1 by convention.
ResultFits in a 64-bit integer
3,628,800
Scientific notation3.6288 x 10^6
Number of digits7
Trailing zeros2
7 digits
Exact<15Large15-50Huge50+
03.286.560510
n

10! has 7 digits.

  • 10! counts the number of distinct orderings (permutations) of 10 items.
  • 10! ends in 2 trailing zeros (each zero comes from a factor of 10 = 2 x 5; fives are counted by Legendre's formula).
  • This result fits within standard exact-integer precision, so every digit is shown.
  • Factorials grow faster than any exponential: each step multiplies by the next whole number.

Next stepUse n! in permutation (nPr = n!/(n-r)!) and combination (nCr = n!/(r!(n-r)!)) formulas.

Factorial table: 0! through 10!

nn!DigitsTrailing zeros
0110
1110
2210
3610
42420
512031
672031
75,04041
840,32051
9362,88061
103,628,80072

Trailing zeros counted by Legendre's formula: floor(n/5) + floor(n/25) + ...

Formula

n!=n×(n1)××1,0!=1,!n=n!/e+0.5,n!!=n×(n2)×n! = n \times (n-1) \times \cdots \times 1,\quad 0! = 1,\quad !n = \lfloor n!/e + 0.5 \rfloor,\quad n!! = n \times (n-2) \times \cdots

Worked example

10! = 10 x 9 x 8 x 7 x 6 x 5 x 4 x 3 x 2 x 1 = 3,628,800 (7 digits, 2 trailing zeros). Double: 10!! = 10 x 8 x 6 x 4 x 2 = 3,840. Derangements: !10 = 1,334,961. Trailing zeros: floor(10/5) = 2.

What a factorial is and how each mode works

The standard factorial n! is the product of every positive integer from 1 up to n. It counts the number of distinct ways to arrange n different objects in a sequence, which is why factorials sit at the heart of permutations and combinations. The double factorial n!! skips every other factor: for even n it multiplies all even integers down to 2, and for odd n it multiplies all odd integers down to 1. The subfactorial !n counts derangements, the permutations where no element occupies its original position; the nearest-integer formula !n = round(n!/e) reveals that roughly 1 in 2.718 permutations are derangements for large n. The multifactorial n(k)! multiplies every k-th integer from n downward, generalising both n! (k=1) and n!! (k=2). The primorial n# is the product of all primes up to n; it appears in proofs about prime gaps and in certain sieve constructions.

Trailing zeros and the Legendre formula

Every trailing zero in n! comes from one factor of 10 = 2 x 5. Because multiples of 2 are far more common than multiples of 5, the number of trailing zeros equals the number of times 5 divides n!. Legendre's formula gives that count directly: add floor(n/5) + floor(n/25) + floor(n/125) + ... until the power of 5 exceeds n. For 100!, this gives 20 + 4 + 0 = 24 trailing zeros, which can be verified by looking at the end of the full 158-digit number. The formula works because floor(n/5) counts multiples of 5, floor(n/25) adds an extra for multiples of 25, and so on.

Stirling's approximation and why factorials grow so fast

Factorials grow faster than any exponential because the multiplier increases at every step. By 13! the result already exceeds six billion; 20! is larger than two quintillion. For very large n, Stirling's approximation ln(n!) approx n*ln(n) - n + 0.5*ln(2*pi*n) is accurate to within a fraction of a percent and can be converted to log base 10 to count digits without computing the full product. The digit count of n! is floor(log10(n!)) + 1, computed here as the sum of log10(k) for k from 2 to n, which never overflows a standard float. Scientific notation with four significant figures is the practical representation once n exceeds about 20.

Applications in mathematics and computing

Factorials appear throughout mathematics. Permutations of n items taken r at a time use n!/(n-r)!, and combinations divide that by r!. Taylor and Maclaurin series approximate sin, cos, and e^x by dividing each power by k!. Probability distributions, including the Poisson and binomial, involve factorials in their mass functions. The gamma function Gamma(n+1) = n! extends the concept to non-integer arguments, and the Stirling series provides its asymptotic expansion. In computing, exact BigInt arithmetic is required for any n above about 20, since 64-bit floating-point numbers can only represent integers exactly up to 2^53. The primorial is used in fast primality tests and in the construction of highly composite number candidates.

Factorial reference table

nn!DigitsTrailing zeros
01 1 0
11 1 0
5120 3 1
103,628,800 7 2
136,227,020,800 10 2
202,432,902,008,176,640,000 19 4
2515,511,210,043,330,985,984,000,000 26 6
50Approx. 3.04 x 10^64 65 12
100Approx. 9.33 x 10^157 158 24
170Approx. 7.26 x 10^306 307 41

Exact values, digit count, and trailing zeros for selected n.

Frequently asked questions

What is 0! and why does it equal 1?

By definition, 0! = 1. There is exactly one way to arrange zero objects (the empty arrangement), and defining it this way keeps the permutation and combination formulas valid without special exceptions. The same logic applies to the empty product in mathematics.

What is a subfactorial or derangement?

The subfactorial !n counts the number of ways to arrange n items so that no item appears in its original position. For example, !3 = 2: given three seats labeled 1, 2, 3 you can sit the three people in exactly two ways such that nobody sits in their own seat (2-3-1 and 3-1-2). The formula is !n = round(n!/e), where e is Euler's number, 2.71828...

What is a double factorial and how is it different from factorial?

The double factorial n!! multiplies only every other integer. For even n: n!! = n x (n-2) x ... x 4 x 2. For odd n: n!! = n x (n-2) x ... x 3 x 1. So 8!! = 8 x 6 x 4 x 2 = 384, while 8! = 40,320. Note that (n!)! is not the same as n!!. Double factorials appear in the Wallis product for pi: pi/2 = 2/1 x 2/3 x 4/3 x 4/5 x 6/5 x ...

How do you count trailing zeros in n!?

Trailing zeros in n! are counted using Legendre's formula: add floor(n/5) + floor(n/25) + floor(n/125) + ... until the power of 5 exceeds n. Each trailing zero requires one factor of 2 and one factor of 5; since factors of 2 are always more plentiful, you only need to count the fives. For n = 100 the count is 20 + 4 = 24 trailing zeros.

What is a primorial?

The primorial n# is the product of all prime numbers up to and including n. For example, 10# = 2 x 3 x 5 x 7 = 210, since 2, 3, 5, and 7 are the primes up to 10. Primorials grow quickly but more slowly than factorials; they appear in number theory proofs about prime gaps and in the construction of candidate smooth numbers.

Can you take the factorial of a negative or decimal number?

The standard factorial is only defined for non-negative integers. The gamma function extends the factorial to positive real numbers and complex numbers via Gamma(n+1) = n!, but that is a separate operation. This calculator accepts only non-negative whole numbers and will return an error for negative or non-integer input.

Why does the calculator switch to scientific notation for large numbers?

Factorials grow extremely fast: 100! already has 158 digits. Showing the full integer would be unwieldy and exceed standard floating-point precision (which can only represent integers exactly up to about 15-16 digits). Scientific notation with a digit count and Stirling's approximation gives the size without losing information on the exponent.

Sources

Written by Dr. Rajiv Menon, PhD Applied Mathematician · Bengaluru, India

Applied mathematician bridging algebraic theory and computational tools for students, engineers, and everyday problem-solvers.

Search 3,500+ calculators

Loading search…