Skip to content

Factorial Calculator

Exact factorials up to 5,000! with every digit, the digit count, trailing zeros, scientific notation, double factorials and Stirling's approximation.

Calculator Details

Factorial:3,628,800See results ↓

A whole number from 0 to 5,000

Your Results

Factorial: 3,628,800

Factorial

3,628,800

10! has 7 digits, 2 trailing zeros

Results

Digits

7

Number of digits in 10!

Trailing zeros

2

Factors of 5 in the product

Scientific notation

3.6288 × 10^6

10 significant digits

Double factorial n!!

3,840

10 × 8 × … (every other number)

Stirling’s approximation

3.598695619 × 10^6

Off by -0.8296%

Every digit of 10! (7 digits)
3,628,800

10! = 3628800, a 7-digit number ending in 2 zeros.

Compare scenarios

Save these inputs as a scenario, change them, and compare the results side by side.

Loading, available in a moment

How This Calculator Works

How the factorial is calculated

10! = 10 × 9 × 8 × 7 × 6 × 5 × … × 1
Trailing zeros = ⌊10/5⌋ = 2
Stirling: √(2π·10) × (10/e)^10 ≈ 3.598695619 × 10^6
012345678910
Digits in k! for k up to n: the count grows a little faster than linearly (about k·log₁₀(k/e)).
How k! grows up to 10!
kk!DigitsTrailing zeros
0110
1110
2210
3610
42420
512031
672031
7504041
84032051
936288061
10362880072

Every digit is exact: the product is worked out with whole-number arithmetic of unlimited size, not floating point, so even 5000! (16,326 digits) is correct to the last digit. Trailing zeros come from pairs of 2 and 5 in the product; there are always more 2s than 5s, so counting the 5s (Legendre’s formula) gives the number of zeros.

Frequently Asked Questions

What is a factorial?

n! (read “n factorial”) is the product of every whole number from 1 to n. 5! = 5 × 4 × 3 × 2 × 1 = 120 and 10! = 3,628,800. It counts the ways to arrange n different things in a row.

Why is 0! equal to 1?

There is exactly one way to arrange nothing: the empty arrangement. It also keeps the rule n! = n × (n − 1)! working at n = 1 (1! = 1 × 0!), and makes formulas such as C(n, 0) = n! ÷ (0! × n!) = 1 come out right. A product with no factors is 1, just as a sum with no terms is 0.

How many ways can a deck of cards be shuffled?

52! = 8.065817517 × 10^67, a 68-digit number. It is so large that any well-shuffled deck is almost certainly in an order that has never existed before.

How do you count the trailing zeros of a factorial?

Each trailing zero comes from a factor of 10 = 2 × 5, and there are always more 2s than 5s, so count the 5s with Legendre’s formula: ⌊n/5⌋ + ⌊n/25⌋ + ⌊n/125⌋ + …. For 100! that is 20 + 4 = 24 zeros.

Why do Excel and phone calculators stop at 170!?

They use 64-bit floating point, which tops out near 1.8 × 10^308. 170! ≈ 7.257 × 10^306 fits, but 171! ≈ 1.241 × 10^309 does not, so they return an overflow error. This calculator multiplies whole numbers of unlimited size, so it gives every digit up to 5,000!.

What is a double factorial?

n!! multiplies every other number down from n: 9!! = 9 × 7 × 5 × 3 × 1 = 945 and 10!! = 10 × 8 × 6 × 4 × 2 = 3840. It is not (n!)!. Double factorials appear in integrals of powers of sine and cosine and in counting perfect matchings.

How accurate is Stirling’s approximation?

n! ≈ √(2πn)·(n/e)ⁿ is always a little low, by about 1/(12n). For 10! it is off by 0.83% and for 100! by 0.0833%, so it is excellent for estimating the size of large factorials in physics and statistics.

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

Not with the ordinary definition, which only covers whole numbers 0, 1, 2…. The gamma function extends it to other numbers, with Γ(n + 1) = n! for whole n (so Γ(1.5) = √π ÷ 2 ≈ 0.886, sometimes written 0.5!). Gamma is undefined at 0 and the negative integers. This calculator covers whole numbers only.

Exact factorials and double factorials of whole numbers from 0 to 5,000, worked out with whole-number arithmetic of unlimited size; scientific notation is rounded half up to 10 significant digits and Stirling’s approximation uses √(2πn)(n/e)ⁿ. Not included: the gamma function (factorials of fractions and negative numbers), larger n (the cap keeps the page responsive), and other variants such as subfactorials and primorials.

Factorial Calculator: Exact n!, Trailing Zeros and Stirling's Formula

By FindMySum · Last reviewed

A factorial calculator multiplies every whole number from 1 up to n. The result, written n!, grows faster than almost any function you meet in school mathematics: 10! is already 3,628,800, and 100! has 158 digits. This calculator gives every digit of n! up to 5,000!, along with the digit count, the number of trailing zeros, the double factorial and Stirling's approximation. This article explains each of them.

The definition

For a whole number n,

n! = n × (n − 1) × (n − 2) × … × 2 × 1

and 0! is defined as 1. The calculator's default is 10:

10! = 10 × 9 × 8 × 7 × 6 × 5 × 4 × 3 × 2 × 1 = 3,628,800

That number has 7 digits and ends in 2 zeros. The same value is the first term of the On-Line Encyclopedia of Integer Sequences entry A000142 that most people check, and what Excel's FACT(10) returns.

Factorials count arrangements. There are n ways to choose the first item in a row, n − 1 for the second, and so on down to one way for the last, so n different objects can be lined up in n! different orders. Ten books on a shelf can stand in 3,628,800 orders; a 52-card deck in about 8.07 × 10⁶⁷.

Why 0! = 1

Three arguments lead to the same answer. There is exactly one way to arrange zero objects (do nothing). The step rule n! = n × (n − 1)! gives 1! = 1 × 0!, which only works if 0! = 1. And a product with no factors is 1, the identity for multiplication, just as an empty sum is 0. Without this convention, formulas for combinations such as C(n, n) = n! ÷ (n! × 0!) would break.

Counting digits and trailing zeros

The number of digits of n! is one more than the integer part of log₁₀(n!). The calculator counts the digits of the exact result directly, so there is no rounding risk at the boundary between, say, 157 and 158 digits.

Trailing zeros are a neater problem. Every zero at the end of a number comes from a factor of 10, which is 2 × 5. Among 1, 2, …, n there are far more even numbers than multiples of 5, so the number of 5s sets the count. Legendre's formula adds them up:

trailing zeros of n! = ⌊n/5⌋ + ⌊n/25⌋ + ⌊n/125⌋ + …

Multiples of 25 contribute an extra 5, multiples of 125 another, and so on. For 100! that gives 20 + 4 = 24 zeros; for 1000!, 200 + 40 + 8 + 1 = 249. The jump at multiples of 25 is why 24! ends in four zeros but 25! ends in six.

Exact digits versus floating point

Spreadsheets and most calculators store numbers as 64-bit floating point, which keeps about 15 to 17 significant digits and overflows above roughly 1.8 × 10³⁰⁸. That means 18! is the last factorial they hold exactly and 170! is the last they can show at all. This calculator multiplies integers of unlimited length, splitting the product into balanced halves so even 5000!, a 16,326-digit number, takes only a few milliseconds. You can copy every digit.

Stirling's approximation

For large n, writing out n! is less useful than knowing its size. Stirling's formula gives it:

n! ≈ √(2πn) × (n/e)ⁿ

It is remarkably good. For 10! it gives about 3,598,696, which is 0.83% low; for 100! the error is 0.083%, and for 1000! it is 0.0083%. The relative error is close to −1/(12n), the first correction term in Stirling's series, as listed in the NIST Digital Library of Mathematical Functions, §5.11. The calculator shows the approximation and its error next to the exact value so you can watch it converge.

Double factorials

The double factorial n!! multiplies every second number down from n:

  • 9!! = 9 × 7 × 5 × 3 × 1 = 945
  • 10!! = 10 × 8 × 6 × 4 × 2 = 3,840

It is not the factorial of a factorial. Double factorials of odd numbers count the ways to pair up an even number of objects (n + 1 people into pairs), and both kinds appear in the integrals of sinⁿx and in physics formulas for spheres in many dimensions. Excel calls it FACTDOUBLE, and its values match OEIS sequence A006882.

Beyond whole numbers

The factorial is defined only for whole numbers 0, 1, 2 and so on. The gamma function extends it smoothly: Γ(n + 1) = n! for whole n, and Γ(1.5) = √π ÷ 2 gives a meaning to "0.5!". Gamma is undefined at zero and at negative integers, which is why there is no −1!. This calculator sticks to whole numbers, where every digit can be exact.

More questions

How can I find the number of digits in n! without calculating it?

Add up the base-10 logarithms: the number of digits is ⌊log₁₀(1) + log₁₀(2) + … + log₁₀(n)⌋ + 1. For large n, Stirling's formula gives the sum almost exactly: log₁₀(n!) ≈ n·log₁₀(n/e) + ½·log₁₀(2πn). For n = 1,000 that is about 2,567.6, so 1000! has 2,568 digits.

What is the last non-zero digit of a factorial?

It is the digit just before the trailing zeros, and it follows its own pattern: 8 for 10! (3,628,800), 4 for 20! and 4 for 100!. There is no simple closed formula, but you can read it off the full digit list the calculator shows.

Which grows faster, n! or 2ⁿ?

n! wins easily. 2ⁿ doubles at each step, while n! multiplies by n, so from n = 4 onwards n! is larger (24 against 16) and the gap keeps widening. Factorials even outgrow any fixed power base, such as 10ⁿ, once n passes about 25. Only functions like nⁿ grow faster.

Where do factorials appear outside counting problems?

In the Taylor series of eˣ, sin x and cos x, where each term is divided by a factorial; in the Poisson and binomial probability formulas; in statistical mechanics, where Stirling's formula turns ln N! into N ln N − N for very large particle counts; and in the gamma function used throughout calculus and statistics.

Is there a factorial key on a scientific calculator?

Usually, marked n! or x!, often as a second function. It gives a rounded value and overflows above 69! on many handheld models (their limit is 10^100) or 170! on most computers. For more digits, or anything larger, use an arbitrary-precision tool such as this calculator.

Sources

This article explains how the calculator works and is general information, not financial, tax, legal or medical advice. Rules change; check the sources above or a qualified professional before you act.

Spotted a wrong result or a bug? Report a problem

May we count your visits with Invoker Analytics? It keeps a random visitor number in your browser. Your calculator inputs are never sent. Privacy policy