How to use the factorial calculator
- 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.
- 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.
- 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.
- 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:
| n | n! | Digits | Trailing zeros |
|---|---|---|---|
| 5 | 120 | 3 | 1 |
| 20 | 2,432,902,008,176,640,000 | 19 | 4 |
| 52 | about 8.06582 × 1067 | 68 | 12 |
| 100 | about 9.33262 × 10157 | 158 | 24 |
| 1,000 | about 4.02387 × 102567 | 2,568 | 249 |
Limits and edge cases
- Exact answers stop at 10,000!, which has 35,660 digits. Larger whole numbers get a message pointing to Stirling's approximation.
- Negative whole numbers have no factorial, so -5 shows an explanation instead of a number.
- Decimals between -170 and 170 use the gamma function: 4.5! ≈ 52.34277778 and 0.5! ≈ 0.8862269255. The value is rounded to 10 significant digits.
- Blank, letters or symbols give a short message under the field, never NaN.
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).