Factorial Calculator (n!)

Get the exact value of n!, how many digits it has and how many zeros it ends with. Decimals work too.

Enter your number

Whole numbers give the exact answer. Decimals use the gamma function. The answer updates as you type.

Try an example

How to use the factorial calculator

  1. Type your number into n. Use a whole number from 0 to 10,000 for an exact answer, or a decimal such as 4.5. The page opens with 10.
  2. Read the result: the value of n! (exact up to 30 digits, scientific notation beyond that), plus Number of digits, Scientific notation and Trailing zeros.
  3. For results longer than 30 digits, the Exact value box holds every digit. Press Copy exact value, and untick Group digits with commas first if you want plain digits.
  4. Tap an example such as 52! or 100!, or press Calculate n!.

How it works

The factorial of a whole number is n! = n × (n - 1) × ... × 2 × 1, and 0! is defined as 1 (MathWorld). Whole numbers are multiplied with exact big-integer arithmetic, so no digit is ever rounded. Trailing zeros come from Legendre's formula: floor(n / 5) + floor(n / 25) + floor(n / 125) + ..., because every zero needs a factor of 5 paired with a 2. For decimals the calculator uses the gamma function, x! = Γ(x + 1) (NIST DLMF 5.2), computed to about 10 significant digits.

Worked example with the default number

With n = 10 the tool shows:

  • 10! = 3,628,800 (that is 10 × 9 × 8 × 7 × 6 × 5 × 4 × 3 × 2 × 1)
  • Number of digits: 7
  • Scientific notation: 3.6288 × 106
  • Trailing zeros: 2, from floor(10 / 5) + floor(10 / 25) = 2 + 0

Factorials grow very fast:

nn!DigitsTrailing zeros
512031
202,432,902,008,176,640,000194
52about 8.06582 × 10676812
100about 9.33262 × 1015715824
1,000about 4.02387 × 1025672,568249

Limits and edge cases

To count arrangements with n! behind the scenes, use the permutation and combination calculator. To turn a long result into a shorter form, try the scientific notation converter.

Frequently asked questions

What is 0 factorial?

0! = 1. It is the empty product, and defining it this way keeps formulas such as C(n, 0) = 1 working.

How many zeros are at the end of 100!?

There are 24. Add floor(100 / 5) + floor(100 / 25) = 20 + 4 = 24. Type 100 to see it under Trailing zeros.

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

Decimals yes, using the gamma function: x! = Γ(x + 1), so 4.5! ≈ 52.34277778. Negative whole numbers have no factorial, though negative decimals such as -0.5 do: (-0.5)! = √π ≈ 1.772453851.

Why does my calculator stop at 69!?

Many scientific calculators cannot show numbers above 10^100, and 70! is about 1.19786 × 10^100. Programs using 64-bit floating point stop at 170!. This tool uses exact big integers, so it keeps going to 10,000!.

What is a factorial used for?

Counting arrangements. n different items can be lined up in n! orders, so a 52-card deck can be ordered in about 8.06582 × 10^67 ways.

Sources: Wolfram MathWorld, Factorial; NIST Digital Library of Mathematical Functions, section 5.2 (gamma function).