Factorial Calculator

Calculate Factorial (n!)

What is a Factorial?

The factorial of a non-negative integer n, denoted by n!, is the product of all positive integers less than or equal to n. For example, 5! = 5 × 4 × 3 × 2 × 1 = 120.

Factorials are fundamental in mathematics, particularly in combinatorics, probability, and calculus. They are used to calculate permutations, combinations, and appear in Taylor series expansions and the Gamma function.

How to Calculate a Factorial

To calculate n!:

  1. Multiply n by (n-1): Start with your number and multiply by one less
  2. Continue down to 1: Keep multiplying by decreasing integers
  3. Special cases: 0! = 1 and 1! = 1

For example, to calculate 5!:

5! = 5 × 4 × 3 × 2 × 1 = 120

Formula

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

0! = 1
1! = 1

Recursive definition:

n! = n × (n-1)! for n > 0
0! = 1

Examples

Calculate 6!

Problem: Find the factorial of 6.

Solution:

  1. 6! = 6 × 5 × 4 × 3 × 2 × 1
  2. 6 × 5 = 30
  3. 30 × 4 = 120
  4. 120 × 3 = 360
  5. 360 × 2 = 720
  6. 720 × 1 = 720
  7. Result: 6! = 720

Factorial Growth Rate

Factorials grow extremely quickly:

  • 5! = 120
  • 10! = 3,628,800
  • 15! = 1,307,674,368,000
  • 20! = 2,432,902,008,176,640,000

Frequently Asked Questions

Why does 0! equal 1?

By definition, 0! = 1. This makes mathematical formulas work consistently. For example, there is exactly one way to arrange zero objects (do nothing), and formulas like n!/((n-k)! × k!) work for all valid values including when k = 0 or k = n.

What is the largest factorial calculators can handle?

In standard JavaScript (which this calculator uses), factorials up to 170! can be accurately represented. 171! exceeds the maximum safe floating-point value. For larger factorials, special arbitrary-precision libraries are needed.

What are factorials used for?

Factorials are essential in: calculating permutations (arrangements) and combinations (selections), probability calculations, Taylor series in calculus, and the Gamma function which extends factorials to non-integers.

Can you calculate the factorial of a negative number?

Factorials are only defined for non-negative integers. However, the Gamma function extends the concept to other numbers, with Gamma(n) = (n-1)! for positive integers.