Skip to main content

Factorial Calculator

Calculate factorial instantly with our math tool. Shows detailed work, formulas used, and multiple solution methods. Free to use with no signup required.

Reviewed by Manoj Kumar, Mathematics Educator

Reviewed by Manoj Kumar, Mathematics Educator

Formula

n! = n * (n-1) * (n-2) * ... * 2 * 1

Where n! (n factorial) is the product of all positive integers from 1 to n. By convention, 0! = 1. Factorials count the number of ways to arrange n distinct objects in order (permutations).

Worked Examples

Example 1: Computing 8! with Trailing Zeros

Problem:Calculate 8! and determine how many trailing zeros it has.

Solution:8! = 8 * 7 * 6 * 5 * 4 * 3 * 2 * 1\n= 56 * 6 * 5 * 4 * 3 * 2 * 1\n= 336 * 5 * 4 * 3 * 2 * 1\n= 1,680 * 4 * 3 * 2 * 1\n= 6,720 * 3 * 2 * 1\n= 20,160 * 2 * 1\n= 40,320\n\nTrailing zeros: floor(8/5) = 1\n8! = 40,320 has 1 trailing zero

Result:8! = 40,320 | 1 trailing zero | 5 digits

Example 2: Factorials in Combinations

Problem:How many ways can you choose 3 items from 10? Use the combination formula with factorials.

Solution:C(10, 3) = 10! / (3! * 7!)\n= 3,628,800 / (6 * 5,040)\n= 3,628,800 / 30,240\n= 120\n\nAlternatively: (10 * 9 * 8) / (3 * 2 * 1) = 720 / 6 = 120

Result:C(10,3) = 10! / (3! * 7!) = 120 ways

Frequently Asked Questions

What is a factorial and how is it calculated?

A factorial of a non-negative integer n, denoted as n!, is the product of all positive integers from 1 to n. For example, 5! = 5 * 4 * 3 * 2 * 1 = 120. By mathematical convention, 0! is defined as 1, which is called the empty product. This definition is necessary to make many formulas in combinatorics and calculus work correctly. Factorials grow extremely rapidly: 10! = 3,628,800, 15! = 1,307,674,368,000, and 20! = 2,432,902,008,176,640,000. This explosive growth rate makes factorials one of the fastest-growing functions commonly encountered in mathematics. The factorial function is central to permutations, combinations, and probability theory.

Why is 0 factorial equal to 1?

The definition 0! = 1 follows logically from the recursive definition of factorials and from combinatorial reasoning. The recursive formula states n! = n * (n-1)!. If we apply this with n = 1: 1! = 1 * 0!, which gives 1 = 1 * 0!, so 0! must equal 1. From a combinatorics perspective, 0! counts the number of ways to arrange zero objects, and there is exactly one way to arrange nothing: do nothing. This is the empty permutation. Additionally, the binomial coefficient C(n, 0) = n! / (0! * n!) must equal 1 (there is one way to choose nothing), which requires 0! = 1. The gamma function, which extends factorials to non-integers, also gives the value 1 at the point corresponding to 0!.

How do you count trailing zeros in a factorial?

Trailing zeros in n! are produced by factors of 10, and each factor of 10 comes from pairing a factor of 2 with a factor of 5. Since factors of 2 are always more abundant than factors of 5 in n!, the number of trailing zeros equals the number of times 5 appears in the prime factorization of n!. This is calculated using Legendre formula: floor(n/5) + floor(n/25) + floor(n/125) + ... For example, 100! has floor(100/5) + floor(100/25) + floor(100/125) = 20 + 4 + 0 = 24 trailing zeros. The first term counts multiples of 5, the second counts multiples of 25 (which contribute an extra factor of 5), and so on for higher powers of 5.

References

Reviewed by Manoj Kumar, Mathematics Educator ยท Editorial policy