Skip to content
Statculator
Probability & Counting

Factorial Calculator (n!)

Factorial calculator: find n! exactly for any whole number from 0 to 5,000, with steps, digit count, trailing zeros and a table of factorials such as 6! = 720.

Free, no sign-up Runs in your browserBy Hira Noor, BS MathematicsUpdated

Try
What do you want to find?

A whole number from 0 to 5,000.

Results

20! (20 factorial)
2,432,902,008,176,640,000
19 digits
Scientific notation
2.4329 × 10¹⁸
Number of digits
19
Trailing zeros
4
log₁₀(n!)
18.3861
ln(n!)
42.3356
Stirling’s approximation
≈ 2.42279 × 10¹⁸
Stirling relative error
-0.4158%
Stirling with 1 + 1/(12n) correction, error
-0.0008%

Interpretation: 20! is the number of different orders in which 20 distinct objects can be lined up: 2,432,902,008,176,640,000.

Factorials from 0! to 20!

kk!
01
11
22
36
424
5120
6720
75,040
840,320
9362,880
103,628,800
1139,916,800
12479,001,600
136,227,020,800
1487,178,291,200
151,307,674,368,000
1620,922,789,888,000
17355,687,428,096,000
186,402,373,705,728,000
19121,645,100,408,832,000
202,432,902,008,176,640,000

Each value is the previous one multiplied by k: k! = k × (k − 1)!.

Step-by-step solution

  1. 1

    Multiply every whole number from n down to 1

    20! = 20 × 19 × 18 × 17 × 16 × 15 × 14 × 13 × 12 × 11 × 10 × 9 × 8 × 7 × 6 × 5 × 4 × 3 × 2 × 1
    = 2,432,902,008,176,640,000
  2. 2

    Count the digits

    A positive integer x has ⌊log₁₀ x⌋ + 1 digits.

    log₁₀(20!) = 18.386125
    Digits = ⌊18.386125⌋ + 1 = 19
  3. 3

    Count the trailing zeros with Legendre’s formula

    Each trailing zero needs a factor 10 = 2 × 5. Factors of 2 are more plentiful, so count the factors of 5 among 1, 2, …, n.

    Zeros = ⌊20/5⌋ = 4
  4. 4

    Compare with Stirling’s approximation

    Stirling’s formula estimates n! without multiplying; its relative error shrinks roughly like 1/(12n).

    n! ≈ √(2πn) · (n/e)ⁿ = √(2π × 20) × (20/e)^20
    ≈ 2.42279 × 10¹⁸
    Relative error = -0.4158% (≈ −1/(12n) = -0.4167%)

What is a Factorial Calculator?

A factorial calculator finds n! (read “n factorial”), the product of every whole number from n down to 1. For example, 6! = 6 × 5 × 4 × 3 × 2 × 1 = 720, and 0! = 1 by definition. This calculator gives the exact value of n! for any whole number from 0 to 5,000, with step-by-step working, the number of digits, the trailing zeros, scientific notation and a check against Stirling’s approximation. It also works backwards: enter a number such as 720 and it tells you which factorial it is.

What the Factorial Calculator does

The factorial of a number n counts the ways to put n different objects in order: 3 books fit on a shelf in 3! = 6 orders, and a deck of 52 cards can be shuffled into 52! ≈ 8.07 × 10⁶⁷ orders. Factorials sit inside every permutation and combination formula, the binomial and Poisson probabilities and the Taylor series of eˣ. They grow faster than any exponential: 10! is about 3.6 million, 25! has 26 digits and 1,000! has 2,568.

A handheld calculator with factorial function (the x! key) rounds large results and stops at 69!, because it cannot show numbers of 10¹⁰⁰ or more, and software built on 64-bit floating point stops at 170!. This n! calculator does every factorial calculation with exact integer arithmetic instead, so you can compute factorial values far beyond those limits without losing a digit. Up to 20! it writes the whole product out, results up to 300 digits are printed in full, and larger values come with scientific notation plus the first and last 60 digits. The trailing-zero count uses Legendre’s formula, and for n ≤ 25 a table lists every factorial from 0! up to your n.

How to use the Factorial Calculator

  1. Leave the mode on n! from n and type a whole number from 0 to 5,000 into Number, n, or tap one of the examples such as 10! or 52!.
  2. Read n! in the results. Up to 24 digits it is shown in full; above that the headline gives scientific notation and the exact digits appear in a table below.
  3. Check the number of digits, the trailing zeros, log₁₀(n!), ln(n!) and the Stirling estimate in the statistics.
  4. Open the step-by-step solution for the multiplied-out product (n ≤ 20), the digit count and the Legendre calculation of the trailing zeros.
  5. To go the other way, switch to Which factorial is x? and type a number such as 720 or 3,628,800. The calculator divides by 2, 3, 4, … and tells you which n! it is, or which two factorials it falls between.

Factorial formula

The factorial of n multiplies n by every smaller positive whole number. Because each factorial is the one before it times one more factor, n! can also be built up one step at a time: 5! = 5 × 4! = 5 × 24 = 120.

Definition
n! = n × (n − 1) × (n − 2) × … × 2 × 1
Zero factorial
0! = 1
Recursive form
n! = n × (n − 1)!
Trailing zeros (Legendre)
Z(n) = ⌊n/5⌋ + ⌊n/25⌋ + ⌊n/125⌋ + …
Number of digits
digits = ⌊log₁₀ n!⌋ + 1
Stirling’s approximation
n! ≈ √(2πn) × (n/e)ⁿ
Formula symbols
SymbolMeaning
na non-negative whole number
n!n factorial, the product of the whole numbers 1 to n
⌊x⌋floor: the largest integer not greater than x
eEuler’s number, 2.71828…

The gamma function extends factorials to non-integers through n! = Γ(n + 1); this calculator handles whole numbers only.

Definitions follow standard references: Factorial, Wolfram MathWorld, NIST Digital Library of Mathematical Functions, §5.4 and the factorial numbers, OEIS A000142.

Worked example: 20 factorial

Find 20!, its digits and its trailing zeros

Problem. Find 20!, its number of digits and its number of trailing zeros.

  1. 0120! = 20 × 19 × 18 × … × 2 × 1 = 2,432,902,008,176,640,000.
  2. 02log₁₀(20!) = 18.386, so the number has ⌊18.386⌋ + 1 = 19 digits.
  3. 03Trailing zeros: ⌊20/5⌋ + ⌊20/25⌋ = 4 + 0 = 4, matching the four zeros at the end.
  4. 04Stirling: √(40π) × (20/e)²⁰ ≈ 2.42279 × 10¹⁸, which is 0.4158% below the exact value.

Answer. 20! = 2,432,902,008,176,640,000, a 19-digit number ending in 4 zeros. It is the largest factorial that fits in a signed 64-bit integer.

How to calculate a factorial

To calculate n!, start at n and multiply by each whole number below it until you reach 1. 3 factorial means 3! = 3 × 2 × 1 = 6, the number of ways to line up three objects: ABC, ACB, BAC, BCA, CAB and CBA. In the same way 4! = 4 × 3 × 2 × 1 = 24 and 6! = 6 × 5 × 4 × 3 × 2 × 1 = 720.

When you already know one factorial, the next is a single multiplication: 7! = 7 × 6! = 7 × 720 = 5,040. Ratios of factorials cancel instead of being multiplied out, so 10! / 8! = 10 × 9 = 90. That cancelling is how the permutation and combination formulas stay manageable.

Which factorial is a number? To find the n with n! = x, divide x by 2, then 3, then 4 and so on until you reach 1. For 720: 720 ÷ 2 = 360, ÷ 3 = 120, ÷ 4 = 30, ÷ 5 = 6, ÷ 6 = 1, so 720 = 6!. If a division leaves a remainder before you reach 1, the number is not a factorial. The Which factorial is x? mode at the top of this page does these divisions for you, even for numbers with thousands of digits.

Factorial table from 0! to 25!

Exact values of the factorials people look up most often, such as 6!, 14! and 25!. Enter any other n above for its exact value and steps.

nn!nn!
0!113!6,227,020,800
1!114!87,178,291,200
2!215!1,307,674,368,000
3!616!20,922,789,888,000
4!2417!355,687,428,096,000
5!12018!6,402,373,705,728,000
6!72019!121,645,100,408,832,000
7!5,04020!2,432,902,008,176,640,000
8!40,32021!51,090,942,171,709,440,000
9!362,88022!1,124,000,727,777,607,680,000
10!3,628,80023!25,852,016,738,884,976,640,000
11!39,916,80024!620,448,401,733,239,439,360,000
12!479,001,60025!15,511,210,043,330,985,984,000,000

Factorial word problems: arranging objects

Books on a shelf. In how many orders can 7 different books stand on a shelf? The first place has 7 choices, the second 6, and so on, so the count is 7! = 5,040.

Arranging letters. The letters of MATH are all different, so they form 4! = 24 arrangements. When letters repeat, divide by the factorial of each repeat count, because swapping identical letters gives nothing new: BOOK gives 4! / 2! = 12, and MISSISSIPPI gives 11! / (4! × 4! × 2!) = 34,650.

Race finishes. Eight runners can finish a race in 8! = 40,320 different orders. If only the first three places matter, use the Permutation Calculator instead: P(8, 3) = 8! / 5! = 336.

Seating around a table. Around a round table only the positions relative to each other count, so fix one person and arrange the rest: 6 people can sit in (6 − 1)! = 5! = 120 distinct ways.

How fast factorials grow

Factorials overtake every exponential function. 2ⁿ doubles at each step, but n! multiplies by n, so the gap widens without limit. The table shows a few landmarks; Stirling’s formula explains why the number of digits grows a little faster than n log₁₀ n.

nn!DigitsTrailing zeros
512031
103,628,80072
202,432,902,008,176,640,000194
52≈ 8.06582 × 10⁶⁷6812
100≈ 9.33262 × 10¹⁵⁷15824
1,000≈ 4.02387 × 10²⁵⁶⁷2,568249

How to do a factorial on a calculator, in Excel and in code

On a TI-83 or TI-84, type n, press MATH, move right to PRB, choose 4: ! and press ENTER. On most Casio scientific models the x! key is SHIFT + x⁻¹. Handheld calculators show about 10 significant digits and spreadsheets 15, so both round large factorials, and they give an error past 69! and 170! respectively. For exact answers use this page; to put factorials inside a longer expression, such as 8! / (3! × 5!), use the Scientific Calculator.

ToolFactorial of nLimits
Excel and Google Sheets=FACT(n)15 significant digits; error above 170
Pythonmath.factorial(n)Exact for any n
Rfactorial(n)Floating point; Inf above 170
TI-84n !Error above 69!
This calculatornExact up to 5,000!

Common use cases

  • Counting arrangements: the orders of n objects, such as 52! ≈ 8.07 × 10⁶⁷ ways to shuffle a deck.
  • Combinatorics: the building block of the permutation and combination formulas, nPr = n! / (n − r)! and nCr = n! / (r!(n − r)!).
  • Probability distributions: the coefficients in the binomial and Poisson formulas.
  • Number theory and programming exercises: digit counts, trailing zeros and checks on big-integer code.
  • Calculus: the denominators of Taylor and Maclaurin series such as eˣ = Σ xⁿ / n!.

Assumptions and limitations

  • Only whole numbers from 0 to 5,000 are accepted. Factorials of negative integers are undefined; non-integers need the gamma function.
  • Results beyond 300 digits are summarized by their leading and trailing digits rather than printed in full.
  • Stirling’s formula is an approximation that always slightly underestimates n!; use the exact value for counting problems.
  • In probability work you usually need a ratio of factorials. Computing it directly with the Combination Calculator avoids handling enormous intermediate numbers.

Frequently asked questions

What is a factorial?

The factorial of a whole number n, written n!, is the product of every whole number from 1 to n. For example, 6! = 6 × 5 × 4 × 3 × 2 × 1 = 720. It counts how many ways n different objects can be arranged in a row.

What does 3 factorial mean?

3 factorial, written 3!, means 3 × 2 × 1 = 6. It is the number of ways to put three different objects in order: with A, B and C those are ABC, ACB, BAC, BCA, CAB and CBA.

What factorial is 720?

720 is 6 factorial: 6! = 6 × 5 × 4 × 3 × 2 × 1 = 720. You can check by dividing 720 by 2, 3, 4, 5 and 6 in turn, which reaches exactly 1. For any other number, choose Which factorial is x? in the calculator above.

Why is 0! equal to 1?

There is exactly one way to arrange zero objects: the empty arrangement. Defining 0! = 1 also keeps the rule n! = n × (n − 1)! consistent at n = 1, and makes formulas like C(n, 0) = 1 and the Poisson probability P(X = 0) = e^(−λ) work without special cases.

How do you do a factorial on a calculator?

On a TI-84, type the number, press MATH, go to PRB and choose “!”. On a Casio, press SHIFT and x⁻¹ for x!. In Excel use =FACT(n). These round large results and stop at 69! or 170!, while this factorial calculator returns the exact value up to 5,000!.

How many trailing zeros does 100! have?

100! ends in 24 zeros. Each zero needs a factor of 10 = 2 × 5, and factors of 5 are the scarcer ones: ⌊100/5⌋ + ⌊100/25⌋ = 20 + 4 = 24. This counting rule is Legendre’s formula.

How many digits does 100! have?

100! has 158 digits. The digit count equals ⌊log₁₀ 100!⌋ + 1, and log₁₀ 100! ≈ 157.97. In scientific notation 100! ≈ 9.33262 × 10¹⁵⁷.

How accurate is Stirling’s approximation?

Stirling’s formula n! ≈ √(2πn)(n/e)ⁿ underestimates n! by a relative error of about 1/(12n): roughly 8% at n = 1, 0.83% at n = 10 and 0.083% at n = 100. Multiplying by 1 + 1/(12n) reduces the error to about 1/(288n²).

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

Not with the ordinary definition. Factorials of negative integers are undefined. For non-integers the gamma function provides an extension, Γ(x + 1), so that for example Γ(5.5) ≈ 52.3428 plays the role of 4.5!. This calculator accepts whole numbers only.

Cite this page

Statculator. (2026, November 14). Factorial Calculator. Retrieved November 14, 2026, from https://statculator.com/probability/factorial-calculator/