Skip to content
FiftyCalc Free calculators for all 50 states

Factorial Calculator

Test cases replayed : 3 of 3 match · Methodology · No outside source listed

Enter a whole number n to get n! = 1 × 2 × … × n, its number of digits and its trailing zeros.

Result

Sample figures

n! (n factorial)—

Number of digits —

  • Trailing zeros—

Estimate for planning only, not tax, legal, financial or medical advice. This calculator uses the method explained on this page.

Factorial Calculator

n (whole number from 0 to 170): enter a number from 0 to 170. Prefilled example: 5.

How to use this calculator

Fill in the fields in this order; each step takes you to its field.

  1. n (whole number from 0 to 170): enter a number from 0 to 170.
  2. Read the result: n! (n factorial); the panel also shows Number of digits and Trailing zeros.

How this calculator works

n! is the product of all whole numbers from 1 to n, and 0! = 1 by definition. It counts the ways to arrange n distinct objects in a row.

The number of digits is ⌊log₁₀ n!⌋ + 1. Trailing zeros come from factors of 10 = 2 × 5; by Legendre's formula their number is ⌊n/5⌋ + ⌊n/25⌋ + ⌊n/125⌋ (enough for n up to 170).

Results up to 20! are exact; larger values are shown rounded to about 16 significant digits, with the right number of digits. 171! is larger than the biggest number a browser can store.

The formula

  1. F=factorial⁡(n)
Symbols used in the formula
SymbolMeaning
nn (whole number from 0 to 170)
Fn! (n factorial)
factorial(n)the product of the whole numbers from one to n.

Worked example

n (whole number from 0 to 170)5
Number of digits3
Trailing zeros1
  1. F=factorial⁡(5)=120

n! (n factorial) 120

Each step uses the unrounded value of the step before it; figures on this page are rounded for display.

Frequently asked questions

What is 5 factorial?

5! = 5 × 4 × 3 × 2 × 1 = 120, a 3-digit number with one trailing zero.

What is 0 factorial?

1. The empty product is 1, which also keeps formulas like n! = n × (n − 1)! true for n = 1.

How many digits does 20! have?

19: 20! = 2,432,902,008,176,640,000, ending in 4 zeros.

Related calculators