Permutation and Combination Calculator
Exact nPr, nCr, circular and repetition counts, with formula steps and an nPr and nCr table.
This factorial calculator finds n! exactly, with steps, for any whole number n from 0 to 10,000. n factorial is the product , so 5! = 120.
100!
93326215443944152681699238856266700490715968264381621468592963895217599993229915608941463976156518286253697920827223758251185210916864000000000000000000000000
158 digits
100! has 158 digits and ends in 24 zeros. Stirling’s formula gets within 0.0833% of it.
Multiply the whole numbers from n down to 1
Exact big-integer arithmetic multiplies all 100 factors without rounding.
Count the digits
A positive integer x has ⌊log₁₀ x⌋ + 1 digits.
Count the trailing zeros (Legendre’s formula)
Each trailing zero needs a factor 10 = 2 × 5. Factors of 2 are far more common, so count the factors of 5: one for each multiple of 5, one more for each multiple of 25, and so on.
Compare with Stirling’s approximation
The approximation is 0.0833% too small, close to the predicted 1/(12n) = 0.08333%.
Double factorial
For even n, n!! multiplies the even numbers and equals 2^(n/2) × (n/2)!.
Every digit is shown up to 3000!, along with the digit count, trailing zeros, double factorial n!! and Stirling’s approximation.
5 or 100. Decimals and negative numbers are not accepted, because n! is defined for whole numbers. For fractions, see the FAQ on the gamma function.Factorial
Plain-text formula: n! = ∏_{k = 1}^n k = n · (n − 1)!, 0! = 1
n! counts the ways to arrange n distinct objects in a row. It grows faster than any exponential function.
Legendre’s formula (trailing zeros)
Plain-text formula: Z(n) = ∑_{k ≥ 1} ⌊n/5^k⌋
The power of a prime p in n! is the sum of ⌊n/pᵏ⌋. With p = 5 it counts the trailing zeros, since every 5 pairs with one of the more plentiful factors of 2.
Stirling’s approximation
Plain-text formula: n! ≈ √(2πn)(n/e)^n, (n!)/(√(2πn) (n/e)^n) ≈ 1 + 1/(12n)
The relative error shrinks like 1/(12n): about 0.83% at n = 10 and 0.083% at n = 100. The approximation is always slightly too small.
Double factorial
Plain-text formula: n!! = n(n − 2)(n − 4)⋯, (2k)!! = 2^k k!
The product stops at 2 for even n and at 1 for odd n. It is not the factorial of a factorial.
Factorials count arrangements: 52! ≈ 8.066 × 10⁶⁷ is the number of ways to shuffle a standard deck, so any well-shuffled order has almost certainly never occurred before. They also appear in combinations, , which the combinations and permutations calculator works out, and in Taylor series and probability.
Because factorials grow so quickly, most software stores them as floating-point numbers and loses digits beyond about 16 significant figures; 171! already overflows double precision. Handheld scientific calculators usually stop at 69!, because 70! ≈ 1.198 × 10¹⁰⁰ is past their 10¹⁰⁰ limit. This calculator uses exact integer arithmetic, so the digits, the digit count, the trailing zeros and the digit sum are all exact.
The factorial of a whole number n, written n! and read “n factorial”, is the product of every whole number from 1 up to n. So 4! = 4 × 3 × 2 × 1 = 24 and 5! = 5 × 4 × 3 × 2 × 1 = 120. The exclamation mark is the factorial symbol.
n! is the number of ways to put n different things in order. Four books can stand on a shelf in 4! = 24 orders: 4 choices for the first place, 3 for the second, 2 for the third and 1 for the last.
By definition 0! = 1. Factorials of negative numbers are undefined, and fractions need the gamma function, .
By hand: start at n and multiply by each smaller whole number down to 1. For 6!: 6 × 5 = 30, × 4 = 120, × 3 = 360, × 2 = 720, × 1 = 720.
Faster, from the one before: each factorial is n times the previous one, . If you know 9! = 362,880, then 10! = 10 × 362,880 = 3,628,800.
Ratios without the full product: cancel before you multiply. , because every factor from 8 down to 1 cancels. This is how permutation counts such as 10P2 are worked out.
Large n: past about 20! the numbers are too long to multiply comfortably, and a phone or spreadsheet loses digits. Use exact arithmetic, as this calculator does, or estimate with Stirling’s approximation.
Values of n! for n from 0 to 20, with the number of digits and trailing zeros. 12! is the largest that fits in a signed 32-bit integer and 20! the largest that fits in a signed 64-bit integer.
| n! | Value | Digits | Trailing zeros |
|---|---|---|---|
| 0! | 1 | 1 | 0 |
| 1! | 1 | 1 | 0 |
| 2! | 2 | 1 | 0 |
| 3! | 6 | 1 | 0 |
| 4! | 24 | 2 | 0 |
| 5! | 120 | 3 | 1 |
| 6! | 720 | 3 | 1 |
| 7! | 5,040 | 4 | 1 |
| 8! | 40,320 | 5 | 1 |
| 9! | 362,880 | 6 | 1 |
| 10! | 3,628,800 | 7 | 2 |
| 11! | 39,916,800 | 8 | 2 |
| 12! | 479,001,600 | 9 | 2 |
| 13! | 6,227,020,800 | 10 | 2 |
| 14! | 87,178,291,200 | 11 | 2 |
| 15! | 1,307,674,368,000 | 13 | 3 |
| 16! | 20,922,789,888,000 | 14 | 3 |
| 17! | 355,687,428,096,000 | 15 | 3 |
| 18! | 6,402,373,705,728,000 | 16 | 3 |
| 19! | 121,645,100,408,832,000 | 18 | 3 |
| 20! | 2,432,902,008,176,640,000 | 19 | 4 |
How many digits does 25! have, how many trailing zeros, and how good is Stirling’s approximation?
Answer: 25! = 15,511,210,043,330,985,984,000,000 has 26 digits and ends in exactly 6 zeros.
0! is an empty product, and an empty product is 1, just as x⁰ = 1. It also keeps the rule n! = n × (n − 1)! working at n = 1, and it makes formulas such as come out right.
10! = 10 × 9 × 8 × 7 × 6 × 5 × 4 × 3 × 2 × 1 = 3,628,800. It has 7 digits and ends in 2 zeros, one from the factor 5 and one from the factor 10.
Cancel the shared factors instead of working out both factorials. Since , the quotient is the product of the whole numbers from k + 1 to n. So and = 9,900. For , use the combinations and permutations calculator.
100! has 158 digits: 93,326,215,443,944,… ending in 24 zeros. It is about 9.333 × 10¹⁵⁷.
24. By Legendre’s formula, ⌊100/5⌋ + ⌊100/25⌋ = 20 + 4. Likewise 1000! ends in 249 zeros.
52! ≈ 8.066 × 10⁶⁷ is the number of orders a 52-card deck can be in. That is so many that a properly shuffled deck is almost certainly in an order no deck has ever been in before.
n!! multiplies every second number down from n: 7!! = 7 × 5 × 3 × 1 = 105 and 8!! = 8 × 6 × 4 × 2 = 384. It is not (n!)!, which would be astronomically larger.
Not with the ordinary definition. The gamma function extends it, with n! = Γ(n + 1), so (1/2)! = Γ(3/2) = √π/2 ≈ 0.8862. Γ has poles at 0 and the negative integers, so factorials of negative whole numbers stay undefined.
20! = 2,432,902,008,176,640,000 fits in a signed 64-bit integer (maximum about 9.22 × 10¹⁸). 21! ≈ 5.1 × 10¹⁹ does not, which is why programs overflow so early.
Exact nPr, nCr, circular and repetition counts, with formula steps and an nPr and nCr table.
Prime factors with division steps, a factor tree, the divisor count and every divisor.
Convert to scientific, E and engineering notation, or add, subtract, multiply and divide, with steps.
Is it prime? Proof by smallest factor, next and previous primes, and a primes list for any range.
LCM and GCF of up to 10 numbers with steps: multiples, prime factors, Euclid’s algorithm and a coprime check.
Type or tap expressions with exact fractions, memory, variables, constants and complex mode.
Results are calculated in your browser with methods checked by automated tests, and are intended for learning and general use. For engineering, medical, financial, legal or safety-critical decisions, verify important values independently and follow the rounding rules your work requires. How accurate are these results?