What Is a Factorial

A factorial is the simplest fast-growing function in math. 5 factorial is 120. 10 factorial is 3.6 million. 70 factorial has more digits than there are atoms in the observable universe.

Tech Talk News Editorial5 min read
ShareXLinkedInRedditEmail
What Is a Factorial

A factorial of a positive integer n is the product of all positive integers from 1 up to n. Written n!. So 5! = 5 × 4 × 3 × 2 × 1 = 120. The exclamation mark notation was introduced by Christian Kramp in 1808 because writing the multiplication out got tedious. The function itself has been studied since at least Indian mathematicians in the 12th century.

The way I think about factorials is that they're the simplest function that grows insanely fast. 10! is 3.6 million. 20! is 2.4 quintillion. 70! exceeds the number of atoms in the observable universe. The reason factorials show up everywhere in combinatorics and probability is that counting arrangements naturally involves multiplying down: pick 1 of 5 options, then 1 of 4 remaining, then 1 of 3, and so on.

Plain English

n! reads as “n factorial.” The exclamation mark is a math symbol here, not punctuation. 0! is defined as 1 by convention (and there's a real reason for that, covered below).

The Definition

Formally:

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

With the special case:

0! = 1

Why is 0! equal to 1? Because the factorial counts the number of ways to arrange a set of n distinct objects, and there's exactly one way to arrange zero objects (the empty arrangement). It also makes the recursive definition consistent: n! = n × (n−1)! works at n = 1 only if 0! = 1.

How Fast Factorials Grow

Some values to give you a feel:

  • 5! = 120
  • 10! = 3,628,800
  • 15! ≈ 1.3 trillion
  • 20! ≈ 2.4 quintillion (2.4 × 10¹⁸)
  • 52! ≈ 8 × 10⁶⁷ (the number of distinct shuffle orderings of a standard deck of cards)
  • 70! ≈ 1.2 × 10¹⁰⁰ (more than the number of atoms in the observable universe, ~10⁸⁰)

Computers running at standard 64-bit integer precision can't store anything past 20!. After that, you need arbitrary-precision integers (BigInteger in Java, big numbers in Python by default).

Why Factorials Show Up

The most common use is counting permutations: the number of ways to arrange n distinct objects in order. If you have 5 books and want to know how many ways you can line them up on a shelf, the answer is 5! = 120. The first slot has 5 choices, the second 4 (one book is gone), the third 3, and so on.

Combinations (where order doesn't matter) use factorials in the formula:

C(n, k) = n! / (k! × (n − k)!)

This is “n choose k,” the number of ways to pick k items from nwhen the order doesn't matter. It's the central object of combinatorics and shows up in everything from poker probabilities to the binomial expansion.

The Famous Card Deck Result

A standard deck of 52 cards has 52! possible orderings, which is roughly 8 × 10⁶⁷. Compare to:

  • Number of seconds since the Big Bang: ~4 × 10¹⁷.
  • Number of atoms on Earth: ~10⁵⁰.
  • Number of atoms in the observable universe: ~10⁸⁰.

52! is bigger than every counting number in cosmology except the universe's atom count. This means: every time you shuffle a deck of cards thoroughly, you're almost certainly producing an ordering that has never existed before in the history of the universe and will never exist again. That's a factorial doing real work.

The Gamma Function

Factorials are defined for non-negative integers. But what about (1/2)! or (2.5)!? The gamma function extends factorials to non-integer values:

Γ(n) = (n − 1)! for positive integers

The gamma function is defined for all complex numbers except non-positive integers, using an integral formula. It satisfies the same recursive relation: Γ(n + 1) = n · Γ(n). So Γ(1/2) = √π, which means (−1/2)! = √π, an unexpected appearance of pi inside a generalized factorial.

Common Identities

Useful relationships:

  • n! = n × (n − 1)! The recursive definition.
  • (n + 1)! / n! = n + 1 Adjacent factorials cancel cleanly.
  • n! / k! = n × (n − 1) × ... × (k + 1) for k < n. The falling factorial.
  • Stirling's approximation: n! ≈ √(2πn) × (n/e)ⁿ. The standard way to estimate factorials for large n without computing them directly.

Where Factorials Appear

Beyond combinatorics:

  • Taylor series. Every Taylor expansion has factorials in the denominators (1/n!).
  • Probability distributions. Poisson, binomial, hypergeometric distributions all use factorials.
  • Counting trees and graphs. Cayley's formula counts labeled trees and uses n^(n-2), which is closely related.
  • Quantum mechanics. Hermite polynomials and harmonic oscillator solutions contain factorials.
  • Cryptography. Permutation cryptosystems leverage the size of n! for security.

Computing Factorials Efficiently

For programmers: factorials grow so fast that for nearly any real-world calculation, you compute the result symbolically or use the gamma function's logarithmic form. Naive iteration works for n ≤ 20 in 64-bit. Beyond that, use big-integer libraries or compute log(n!) by summing log(k) from 1 to n, which is what most statistics libraries do internally.

Takeaway

n! = n × (n−1) × ... × 2 × 1, with 0! = 1. Factorials grow faster than exponentials and dominate combinatorial counting. They generalize through the gamma function to non-integers. They show up in Taylor series, probability, and combinatorics. The fact that 52! is larger than the number of atoms on Earth is the cleanest way to internalize how fast factorials grow.

The Take

Factorials are one of those concepts that's simple to define and impossible to fully grasp without examples. The card-deck result is the example. Once you accept that one shuffle of one deck produces an arrangement that has likely never existed before in the universe, the rest of factorial math is easier to take seriously. They're the simplest function in math that breaks human intuition about “a really big number.”

Written by

Tech Talk News Editorial

Tech Talk News covers engineering, AI, and tech investing for people who build and invest in technology.

ShareXLinkedInRedditEmail