Skip to content
Omnikalc

Factorial calculator: n!, double factorial, digits and trailing zeros

Enter a whole number to get its factorial, the double factorial, the number of digits and the number of trailing zeros.

Updated on
Your inputs

Value out of range

Results

n factorial (n!)

3,628,800

Double factorial (n!!)
3,840
Trailing zeros of n!
2
Number of digits of n!
7

Factorials count orderings and appear in nearly every counting formula. The factorial calculator takes a whole number n and gives n!, the double factorial n!!, the number of trailing zeros and the number of digits of n!.

How the calculation works

  • Enter a whole number n from 0 to 170.
  • The factorial is n! = n × (n − 1) × … × 2 × 1, with 0! defined as 1. It counts the ways to put n distinct items in order.
  • The double factorial n!! multiplies every second number: n × (n − 2) × (n − 4) × … down to 2 or 1.
  • Trailing zeros come from factors of 10, and each needs a 2 and a 5. There are always more 2s than 5s, so the count is ⌊n ÷ 5⌋ + ⌊n ÷ 25⌋ + ⌊n ÷ 125⌋.

Example

For n = 10, 10! = 10 × 9 × … × 1 = 3,628,800. The double factorial is 10 × 8 × 6 × 4 × 2 = 3,840. The number has 7 digits and 2 trailing zeros, since 10 ÷ 5 = 2 and there are no multiples of 25.

Why it matters

Students of probability, algebra and computer science use factorials for permutations, combinations and series. Knowing the digits and the trailing zeros is a classic exercise, and a quick tool saves long multiplications. The double factorial also appears in formulas for the volume of spheres, in series expansions and in some counting problems.

Good to know

Factorials above about 20 exceed the exact range of ordinary integers, and this calculator uses floating-point arithmetic, so large results are rounded. The tool stops at 170, because 171! is beyond the largest number a double can hold.

The combinations and permutations calculators use factorials to count selections and orderings.

Frequently asked questions

What is a factorial?

The factorial of a non-negative whole number n is the product of all whole numbers from 1 to n. It counts the number of ways to arrange n different objects in a row. By convention, 0! equals 1.

Why is 0! equal to 1?

There is exactly one way to arrange zero objects, which is to do nothing. The convention also keeps formulas such as the binomial coefficient and the exponential series consistent.

What is the double factorial?

The double factorial n!! multiplies every second number down from n. So 7!! = 7 × 5 × 3 × 1 = 105 and 8!! = 8 × 6 × 4 × 2 = 384. It is not the factorial of a factorial.

How do I count the zeros at the end of n!?

Each trailing zero comes from a factor of 10, which needs a 2 and a 5. There are many more 2s than 5s, so you only need to count the 5s, including the extra 5s in multiples of 25 and 125.

Was this calculator helpful?

Thanks for your feedback!

Results are estimates provided for information purposes. They do not replace professional advice.