🧰 ToolPicoAll Tools →

Factorial Calculator (n!)

Calculate n! with BigInt up to 10000! without losing a single digit. Includes step-by-step expansion, scientific notation, double/multifactorial, subfactorial (derangement), permutations, and combinations — all instant and free.

Exact up to 10000! with BigInt 171! → Number overflows 0! = 1 Updated: Jul 27, 2026
The product of every whole number from 1 to n is calculated. 0! = 1.
If n is even: n×(n−2)×...×2. If n is odd: n×(n−2)×...×1.
n(k)! = n×(n−k)×(n−2k)×... down to a value between 1 and k. k=1 is the ordinary factorial; k=2 is the double factorial.
The number of permutations in which no element stays in its original position.
A non-integer factorial is defined by the Gamma function: x! = Γ(x+1). E.g. 0.5, 2.5, 4.5, -0.5.
Compare two factorials: the ratio of the larger to the smaller (n!/m!) is calculated as an exact whole number.
⚙️ Advanced settings — expansion limit, scientific notation, thousands separator
Show thousands separatorGroup the whole number like 1,000
Quick answer Factorial (n!) is the product of all positive integers from 1 to n; 0! is defined as 1. The result grows extremely fast and exceeds the limits of a standard Number after about 18–20!; this tool uses BigInt to give the exact result up to 10000!, with every digit, plus scientific notation.
10! definition (empty product)
171n ≥ this value overflows Number
158digits in 100!
35660digits in 10000!
⚙️ Accuracy note: All factorial, double factorial, multifactorial, subfactorial (derangement), permutation, and combination results are calculated with JavaScript BigInt arithmetic — no decimal rounding is applied and no digit is ever lost. Inputs for n are limited to the 0–10000 range (even 10000! is computed in milliseconds at full precision). Scientific notation and Stirling's approximation are shown only for readability and cross-checking; the underlying result is always the exact value.

What is a factorial, and how is it calculated?

A complete guide — with formulas and examples — to factorial, its recursive rule, BigInt for large numbers, double factorial, and subfactorial.

A factorial, denoted by an exclamation mark (!) after a whole number n, is the mathematical operation representing the product of all positive integers from 1 to n: n! = n × (n−1) × (n−2) × ... × 2 × 1. Factorial is one of the fundamental building blocks of combinatorics, permutations, combinations, probability calculations, and series expansions (e.g. the Taylor series).

What is the factorial formula and its recursive rule?

Quick answerThe factorial formula is n! = n × (n−1) × ... × 2 × 1; it can also be written recursively as n! = n × (n−1)!, with 0! = 1 as the base case (the empty-product rule). For very large n, the approximate value can be found with Stirling's formula: n! ≈ √(2πn) × (n/e)^n.
  • Base case: 0! = 1, 1! = 1.
  • Recursion: every n! is the previous (n−1)! multiplied by n.
  • Growth rate: factorial grows even faster than an exponential function (a^n) — this is called super-exponential growth.

Why is factorial calculated with BigInt for large numbers?

Quick answerJavaScript's ordinary Number type can hold integers exactly only up to about 2^53 (≈9 quadrillion); this limit is exceeded around 18!–19!, and starting at 171! a Number overflows to Infinity. This tool performs every multiplication step with BigInt, producing an exact result, with every digit, up to 10000!.

In practice, this means that questions like "how many digits?" or "exactly which digits does it end in?" can only be answered correctly with BigInt (or similar arbitrary-precision arithmetic). A standard calculator or calculator app usually shows a rounded/approximate value after 20!; this tool instead stores the exact value and shows it on demand.

What are double factorial (n!!) and subfactorial (!n)?

Quick answerThe double factorial n!! is a product that decreases by 2 each step (e.g. 7!!=7×5×3×1=105). The subfactorial !n (derangement number) is the number of permutations of an n-element set in which no element stays in its original position (e.g. !4=9). Both are used in specialized combinatorics problems (series expansions, probability, distribution problems).

What is a multifactorial (n(k)!)?

Quick answerThe multifactorial n(k)! generalizes the double factorial to any step size k: n×(n−k)×(n−2k)×... down to a value between 1 and k (e.g. the triple factorial 9(3)!=9×6×3=162). k=1 gives the ordinary factorial and k=2 gives the double factorial, so n!! and n! are just special cases of this single formula.

Factorial examples, small to large

The most frequently searched n! values — exact result and digit count. For exact and decimal results, use the calculator above.

Frequently searched factorial values (exact result, calculated with BigInt)
nn!Digits

Popular calculations

Related calculators: permutation, combination, trailing zeros & primorial

The most common uses of factorial — ordered selection (permutation), unordered selection (combination), the trailing zero count of n!, and the prime-only primorial (n#) — all with exact BigInt results.

🔢Permutation (nPr)
The number of ordered arrangements of r items chosen from n: nPr = n! / (n−r)!.
🎯Combination (nCr)
The number of unordered selections of r items from n: nCr = n! / (r!·(n−r)!).
0️⃣Trailing Zero Count
Finds how many zeros n! ends with, using Legendre's formula: ⌊n/5⌋+⌊n/25⌋+...
✳️Primorial (n#)
The product of all prime numbers ≤ n (or the first n primes), the "prime-only" cousin of factorial.

Reference tables & practical facts

Citable exact values: small factorials, digit counts for large factorials, double/multifactorial, subfactorial, and permutation/combination formulas.

Exact values of 0! – 20!
nn!
Large factorials — scientific notation and exact digit count (calculated with BigInt)
nScientific notationDigits

Note: 170! is the largest factorial that can be computed without overflow in the IEEE-754 double (Number) type; 171! returns Infinity with Number.

Double factorial (n!!) table, n=0–12
nn!!
Multifactorial (n(k)!) examples for different step sizes k
n(k)!Result

n(k)! = n×(n−k)×(n−2k)×... down to a value between 1 and k. Use the "Multi (n(k)!)" tab above for any n and k.

Subfactorial / derangement (!n) table, n=0–12
n!n
Permutation / Combination formulas and example (n=10, r=3)
FormulaMeaningExample (n=10,r=3)
P(n,r) = n! / (n−r)!Ordered selection (permutation)
C(n,r) = n! / (r!·(n−r)!)Unordered selection (combination)
P(n,r) / r!Relationship between P and CEqual to C(n,r)

Factorial terms glossary

Short definitions of the core terms used in factorial and combinatorics.

Factorial (n!)The product of all positive integers from 1 to n. 0! is defined as 1.
Empty productThe rule that a product of no numbers equals 1; the mathematical basis for 0! = 1.
Double factorial (n!!)A product starting at n and decreasing by 2 each step. Ends at 2 if n is even, 1 if odd.
Multifactorial (n(k)!)Generalizes n! and n!! to any step size k: n×(n−k)×(n−2k)×... down to 1–k.
Subfactorial / Derangement (!n)The number of permutations in which no element remains in its original position.
Permutation (nPr)The number of ordered ways to arrange r items chosen from n: n!/(n−r)!.
Combination (nCr)The number of unordered ways to choose r items from n: n!/(r!(n−r)!).
Stirling's approximationA formula for approximating n! for large n: n! ≈ √(2πn)·(n/e)^n.
Scientific notationA way of writing very large numbers as a×10^b using the first few significant digits.
Digit countThe number of digits in a whole number's decimal representation; for n! it's approximately log10(n!)+1.
Trailing zero countHow many zeros n! ends with; equal to the number of factors of 5 in the product (Legendre's formula).
BigIntA JavaScript data type that can hold arbitrarily large integers exactly, with no rounding.
Super-exponential growthThe property of factorial growing even faster than exponential functions (a^n).

In-depth guides

Detailed answers to the most commonly asked factorial questions.

How many digits does 100 factorial have? How is it calculated?

100! has exactly 158 digits and is approximately equal to 9.332621544×10^157. The digit count can also be estimated by taking the integer part of log10(100!) and adding 1 (Stirling's approximation gives ≈157.97, +1 = 158). Enter 100 into this tool and press Calculate on the "n!" tab to instantly see the exact 158-digit result, the scientific notation, and the digit count.

Computing the digit count exactly with BigInt, rather than relying on memorized approximations, gives a precise and undisputable answer for homework, research verification, or programming interview questions (e.g. "how many digits does n! have?").

Why does factorial grow so fast? (explained with Stirling's formula)

Factorial grows even faster than exponential functions (e.g. 2^n) because at every step it multiplies the previous result by an ever-increasing number — this is called super-exponential growth. Stirling's approximation (n! ≈ √(2πn)·(n/e)^n) explains this growth mathematically: the (n/e)^n term is the main driver.

Concrete example: 20! is approximately 2.43×10^18, while 25! is approximately 1.55×10^25 — a jump of just 5 in n makes the result more than 10 million times larger. That's why, from around 20! onward, ordinary calculators approach the limits of a standard Number, and BigInt (as used in this tool) becomes necessary.

How is factorial used in permutations and combinations?

Permutation (nPr) gives the number of ordered arrangements/selections of r items chosen from n, using the formula nPr = n!/(n−r)!. Combination (nCr) is selection without regard to order, using the formula nCr = n!/(r!·(n−r)!) — combination is permutation divided by r!, because in a combination, all the orderings of the same r items count as a single selection.

For example, choosing an ordered award ranking (1st, 2nd, 3rd) of 3 people from a group of 10 has P(10,3)=720 possible outcomes, while choosing the same 3 people as an unordered committee has only C(10,3)=120 possible selections. Use the mini tools above to calculate instantly with your own n and r values.

Frequently asked questions

What is a factorial?
A factorial, denoted by an exclamation mark (!) after a positive integer n, is the product of all positive integers from 1 to n. For example, 5! = 5×4×3×2×1 = 120. Factorials form the basis of permutation, combination, and probability calculations.
What is 0 factorial?
0! = 1. This comes from the mathematical rule of the "empty product": when no numbers are multiplied together, the result is defined as 1, the multiplicative identity. This definition also keeps the recursive rule n! = n × (n−1)! consistent at n = 1 (1! = 1 × 0! = 1).
How is factorial calculated for large numbers?
JavaScript's ordinary Number type can hold integers exactly only up to about 2^53; this limit is exceeded around 18!–19!, and starting at 171! a Number overflows to Infinity. That's why large factorials are calculated with the BigInt data type. This tool produces an exact result, with every digit, up to 10000!.
What is the factorial formula?
The factorial formula is n! = n × (n−1) × (n−2) × ... × 2 × 1; it can also be written recursively as n! = n × (n−1)!, with 0! = 1 as the base case. For very large n, the approximate value can be found with Stirling's formula: n! ≈ √(2πn) × (n/e)^n.
What is a double factorial (n!!)?
The double factorial n!!, starting at n, decreases by two at a time: if n is even, n!!=n×(n−2)×...×2; if n is odd, n!!=n×(n−2)×...×1. For example, 7!!=7×5×3×1=105 and 8!!=8×6×4×2=384. By definition, 0!!=1 and 1!!=1.
What is a multifactorial (n(k)!)?
The multifactorial n(k)! generalizes the double factorial to any step size k: it multiplies n by n−k, n−2k, and so on down to a value between 1 and k. For example, the triple factorial 9(3)!=9×6×3=162, and the quadruple factorial 10(4)!=10×6×2=120. The ordinary factorial is the special case k=1, and the double factorial is k=2. Use the "Multi (n(k)!)" tab above to calculate this for any n and k.
How many digits does 100 factorial have?
100! has exactly 158 digits and is approximately equal to 9.332621544×10^157. Enter 100 into the calculator above and press Calculate to instantly see the exact 158-digit result along with the scientific notation.
What is a subfactorial (derangement, !n)?
The subfactorial !n (derangement number) is the number of permutations of an n-element set in which no element remains in its original position. !0=1, !1=0, !2=1, !3=2, !4=9, and the general recursive rule is !n=(n−1)×(!(n−1)+!(n−2)).
How do you find the number of trailing zeros in a factorial?
The number of trailing zeros in n! equals the number of factors of 10 (2×5 pairs) in the product, and in practice depends on how many times 5 appears as a factor. Using Legendre's formula, the trailing zero count = ⌊n/5⌋+⌊n/25⌋+⌊n/125⌋+.... For example, 100! ends in exactly 24 zeros.
Can you calculate a decimal factorial (like 0.5!)?
Yes. The factorial of a non-integer is defined using the Gamma function, which generalizes factorial to all real numbers: x! = Γ(x+1). For example, 0.5! = √π ⁄ 2 ≈ 0.8862 and (−0.5)! = √π ≈ 1.7725. Enter a value like 0.5, 2.5, or 4.5 into the "Decimal (x!)" tab above to see this result instantly, computed with the Lanczos approximation (~10 significant digits). Because the Gamma function has poles at non-positive integers (0, −1, −2, …), factorial is undefined at those values.

Methodology & sources

ToolPico's Factorial Calculator is a free, independent tool. The calculation engine runs entirely in your browser using JavaScript BigInt arithmetic: every multiplication step is performed at full integer precision, with no decimal rounding applied. Scientific notation, digit count, and Stirling's approximation are shown only to make the result readable and to cross-check it; the whole number displayed is always the exact value. Trailing zero count is computed with Legendre's classic formula, and subfactorial with the standard recursive rule.

Sources: Classic combinatorics definitions (factorial, double factorial, derangement), Stirling's approximation, and Legendre's formula for prime factorization — all universal and time-invariant mathematical facts. Last updated: July 27, 2026. Results are for educational and informational purposes only.

Explore all ToolPico tools →

Add this calculator to your site (embed code)

Embed the factorial calculator on your own website for free. Copy the code below into your HTML — the tool runs in a simplified view and links back to this page as its source.

The embedded tool has a fixed layout; you can adjust the height value to fit your site. No ads or personal data, runs entirely client-side.

🔗 Add this tool to your site

Copy the code below into your own site. The tool is free, always up to date, and runs entirely on your page. No sign-up required.

Preview →
⚡ Built with ToolPico · toolpico.com