AJ Designer

Factorial Calculator

n factorial equals n times n minus 1 times dot dot dot times 2 times 1

Solution

Share:

Factorial Calculator

Calculate the factorial of a non-negative integer. The factorial is the product of all positive integers up to n. By definition, 0! = 1.

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

How It Works

The factorial of a non-negative integer n, written as n!, is the product of all positive integers less than or equal to n. By definition, 0! = 1. For example, 5! = 5 × 4 × 3 × 2 × 1 = 120. Factorials grow extremely fast, which is why even modest inputs produce very large outputs. They are fundamental in combinatorics, probability, and algebra.

Example Problem

Find 7!:

  1. Write the factorial expansion: 7! = 7 × 6 × 5 × 4 × 3 × 2 × 1.
  2. Multiply the first two factors: 7 × 6 = 42.
  3. Continue downward: 42 × 5 = 210.
  4. Then 210 × 4 = 840.
  5. Then 840 × 3 = 2,520.
  6. Then 2,520 × 2 = 5,040.
  7. Multiplying by 1 leaves the result unchanged, so 7! = 5,040.

Therefore, 7! = 5,040.

Key Concepts

The factorial function n! is defined as the product of all positive integers from 1 to n, with the special case 0! = 1 (the empty product). Factorials grow faster than any exponential function — Stirling's approximation (n! ~ sqrt(2*pi*n) * (n/e)^n) is often used for large n. The gamma function extends factorials to non-integer and complex arguments, with Gamma(n+1) = n! for non-negative integers.

Applications

  • Combinatorics: calculating permutations (n!) and combinations (n choose k = n! / (k!(n-k)!))
  • Probability theory: computing binomial, Poisson, and multinomial distribution probabilities
  • Taylor series: denominators of Taylor expansion terms use factorials (e.g., e^x = sum of x^n/n!)
  • Computer science: analyzing algorithm complexity for brute-force permutation searches (O(n!))

Common Mistakes

  • Forgetting that 0! = 1 — this is not arbitrary but necessary for combinatorial formulas to work correctly
  • Underestimating factorial growth — 20! already exceeds 2.4 quintillion, causing overflow in 32-bit integers at just 13!
  • Trying to compute factorials of negative integers — the factorial function is undefined for negative integers (use the gamma function for non-integers)

Frequently Asked Questions

How do you calculate a factorial step by step?

Write the number as a descending product and multiply one factor at a time. For example, 6! = 6 × 5 × 4 × 3 × 2 × 1 = 720.

What is the formula for factorial?

The factorial formula is n! = n × (n - 1) × (n - 2) × ... × 2 × 1 for any non-negative integer n. The special case 0! is defined as 1.

Why is 0! equal to 1?

By convention, 0! = 1. This is because the product of zero factors is the multiplicative identity (1), and it ensures that formulas like the binomial coefficient and permutations work correctly for edge cases.

What is the largest factorial this calculator supports?

This calculator supports values up to 170!. Beyond 170, the result exceeds the range of standard JavaScript floating-point numbers. The exact integer result is computed using high-precision arithmetic.

Where are factorials used?

Factorials appear in permutations, combinations, Taylor series expansions, probability distributions, and many areas of discrete mathematics and computer science.

Can you take the factorial of a negative number?

The factorial function is only defined for non-negative integers. The gamma function extends the concept to all complex numbers except negative integers.

How fast do factorials grow?

Factorials grow faster than exponential functions. While 10! = 3,628,800, by 20! the result is already over 2.4 quintillion. Stirling's approximation is often used for large n.

Reference: Standard factorial definition from combinatorics and discrete mathematics, with 0! defined as the empty product equal to 1.

Factorial Formula

The factorial of a non-negative integer multiplies every whole number from that integer down to 1:

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

Where:

  • n is a non-negative integer
  • n! is the product of all positive integers up to n
  • 0! is defined as 1

Factorials are fundamental in permutations, combinations, probability, and series expansions.

Worked Examples

Small Integer

Find 5!

  • 5! = 5 × 4 × 3 × 2 × 1
  • 5 × 4 = 20
  • 20 × 3 = 60
  • 60 × 2 = 120

Result: 5! = 120

Counting Arrangements

Find 7!

  • 7! = 7 × 6 × 5 × 4 × 3 × 2 × 1
  • Multiply left to right: 42, 210, 840, 2,520, 5,040
  • This is the number of ways to arrange 7 unique items

Result: 7! = 5,040

Edge Case

Why is 0! equal to 1?

  • 0! is defined as the empty product
  • An empty product equals 1 so combinatorics formulas still work
  • That is why 0! is not 0

Result: 0! = 1

Related Calculators

Related Sites