What Is a Factorial, and Why Does It Grow So Fast

A factorial, written n!, multiplies every whole number from 1 up to n, so 5! is 120. The function is trivial to define and outgrows the atom count of the universe by n = 59.

Tech Talk News Editorial8 min readUpdated Nov 18, 2026
#factorials#mathematics#combinatorics#math basics
ShareXLinkedInRedditEmail
What Is a Factorial, and Why Does It Grow So Fast

Key takeaways

  • A factorial, written n!, is the product of every whole number from 1 up to n, so 5! = 5 x 4 x 3 x 2 x 1 = 120, and 0! is defined as 1.
  • Factorials overtake powers of 2 at n = 4 (24 versus 16) and the gap keeps widening: 10! is 3,628,800 while 2^10 is only 1,024, and 20! is 2,432,902,008,176,640,000.
  • 59! is about 1.39 x 10^80, which passes the roughly 10^80 atoms in the observable universe, and 52!, the number of orderings of a shuffled deck, is about 8.07 x 10^67.
  • A 32-bit integer holds factorials only up to 12! (479,001,600), and a signed 64-bit integer holds them only up to 20!, so larger values need arbitrary-precision integers or logarithms.
  • The gamma function extends factorials to non-integers through n! = gamma(n + 1), which gives (1/2)! of about 0.8862 and (-1/2)! equal to the square root of pi.

A factorial, written n!, is the product of every whole number from 1 up to n. So 5! = 5 × 4 × 3 × 2 × 1 = 120, and by convention 0! = 1.[1] The factorial of n is also the number of ways to line up n different things in a row, which is why it shows up anywhere you count arrangements.

It's also the cheapest way I know to break your intuition about big numbers. The definition fits on a napkin, and by n = 59 the answer is larger than the number of atoms in the observable universe.

120
5 × 4 × 3 × 2 × 1
5!
3,628,800
About 3.6 million
10!
2.4 × 10¹⁸
2,432,902,008,176,640,000
20!
8.07 × 10⁶⁷
Orderings of a card deck
52!

Summary

Read n! as “n factorial.” The exclamation mark is a math symbol here, not punctuation. The notation comes from French mathematician Christian Kramp, who introduced it in 1808.[1] The idea is much older: one of the earliest descriptions is in the Jain text Anuyogadvāra-sūtra, and Bhāskara II wrote about it in his Līlāvatī in 1150.[2]

How to calculate a factorial

Multiply the number by every whole number below it, down to 1. The easier way to do it by hand is to build up, because each factorial is the previous one times the new number: 1! = 1, 2! = 2 × 1 = 2, 3! = 3 × 2 = 6, 4! = 4 × 6 = 24, 5! = 5 × 24 = 120.

That one-step relationship, n! = n × (n − 1)!, is the entire definition. Everything else in this post follows from it.

Why 0! equals 1

This is the question people actually search, and the honest answer is that the definition was chosen so nothing breaks. Three reasons point the same direction.

  • Counting. n! counts the ways to arrange n items. There is exactly one way to arrange zero items: the empty arrangement.
  • The empty product. A product of no numbers is 1, the same way a sum of no numbers is 0.[2]
  • The recursion. n! = n × (n − 1)! only works at n = 1 if 0! = 1, since 1! = 1 × 0!.

There's a fourth test I like better than any of them. Choosing all 5 items from 5 should give exactly 1 way. The combinations formula says 5! / (5! × 0!), and that only equals 1 if 0! is 1.[2] Define it any other way and a formula that works for every other case suddenly needs a footnote.

How fast factorials grow

Factorials start slower than powers of 2 and then leave them behind. At n = 3, 3! is 6 and 2³ is 8. At n = 4, 4! is 24 and 2⁴ is 16, and from there the gap only widens. 10! is 3,628,800 while 2¹⁰ is 1,024.

Powers of 2 (2ⁿ)

Factorial (n!)

  1. n = 5
    32 (2 digits)
    120 (3 digits)
  2. n = 10
    1,024 (4 digits)
    3,628,800 (7 digits)
  3. n = 20
    1,048,576 (7 digits)
    2.4 × 10¹⁸ (19 digits)
  4. n = 52
    4.5 × 10¹⁵ (16 digits)
    8.07 × 10⁶⁷ (68 digits)
Bar length is the number of digits in the value, because the values themselves are too far apart to draw. Digit counts computed with Python's exact integers.

Takeaway

Each step adds about 0.3 digits to 2ⁿ. Each step adds log₁₀(n) digits to n!, which is about 1.7 at n = 52 and keeps rising. By n = 52 the factorial has more than four times as many digits.

Here's the part I find genuinely fun. The observable universe holds about 10⁸⁰ atoms.[6] 58! is about 2.35 × 10⁷⁸, still under that. 59! is about 1.39 × 10⁸⁰, over it.

One more multiplication by 59 is all it takes to pass every atom there is. If you'd like it in cards, 52! is about 8.07 × 10⁶⁷, while the universe is only about 13.787 billion years old, roughly 4.4 × 10¹⁷ seconds.[6]

“A thoroughly shuffled deck has almost certainly never been in that order before, and almost certainly never will be again.”

What factorials count

The reason factorials turn up everywhere is that counting orderings is naturally a chain of shrinking choices. Five books on a shelf: 5 choices for the first slot, 4 for the second, 3 for the third, and so on, so 5! = 120. Change the question slightly and the same factorial parts get rearranged.

Counting with factorials

The question you ask picks the formula

What you are counting (5 books)

  • All 5 books in a rowOrder matters, use every book
  • 3 of the 5 on a shelfOrder matters, use some
  • 3 of the 5 in a bagOrder does not matter

Factorials

Divide out the choices you do not care about

Formula and answer

  • n! = 1205 × 4 × 3 × 2 × 1
  • n! / (n − k)! = 605! / 2!
  • n! / (k! × (n − k)!) = 105! / (3! × 2!), "n choose k"
Different formulaRepeats allowed: nᵏPicking 3 books with replacement gives 5³ = 125, which is not a factorial problem.

Each step divides out arrangements you consider the same. Dividing by 2! removes the two unused books; dividing by 3! as well ignores the order of the three chosen.

The last row, C(n, k), is “n choose k.” It sits underneath poker odds, the binomial theorem and lottery math. For example, the number of 5-card hands from a 52-card deck is C(52, 5), which is 2,598,960.

Beyond counting, factorials appear as the denominators in Taylor series (which is how a calculator computes sine, and a quiet link to the law of sines), and inside the Poisson and binomial probability formulas.

In computer science the worst case of trying every ordering is O(n!). A brute-force route search over 10 stops means 3,628,800 orderings, and over 15 stops it's about 1.3 trillion. Big O notation is the shorthand for that kind of growth.

Factorials of fractions: the gamma function

The definition only covers whole numbers. The gamma function fills the gaps: n! = Γ(n + 1) for every whole n, and Γ is defined for non-integers too.[3] It obeys the same recursion, Γ(z + 1) = z · Γ(z), so it behaves like a factorial in between the integers.

The surprise is where pi shows up. Γ(1/2) = √π, about 1.7725, so (−1/2)! equals the square root of pi.[3] The half factorial is (1/2)! = Γ(3/2) = √π / 2, about 0.8862, and (2.5)! = Γ(3.5), about 3.3234. It still breaks at negative whole numbers, where gamma has no value, so (−1)! stays undefined.

Computing big factorials in code and spreadsheets

Computers hit a wall quickly. A 32-bit integer tops out at 4,294,967,295 unsigned, so it holds factorials only through 12! (479,001,600). A signed 64-bit integer holds them through 20!. Past that you need arbitrary-precision integers, which Python uses by default, or you work in logarithms.

factorial.pyPython
import math

math.factorial(5)    # 120
math.factorial(20)   # 2432902008176640000
math.factorial(52)   # 80658175170943878571660636856403766975289505440883277824000000000000

# log10(52!) without building the 68-digit integer: lgamma(n + 1) is ln(n!)
math.lgamma(53) / math.log(10)   # 67.9066...
Exact integers for any size, and a logarithm route when you only need the magnitude.

Python's math.gamma and math.lgamma are the gamma function and the natural log of its absolute value, and since Python 3.10 math.factorial no longer accepts floats such as 5.0.[7]

In Google Sheets the function is =FACT(5), which returns 120, and it silently truncates a decimal input before computing.[5] The same sheet is usually where you also need the spread of your numbers, which is covered in standard deviation in Google Sheets.

When you only need an estimate, Stirling's approximation does it: n! ≈ √(2πn) × (n/e)ⁿ.[4] It's low by about 0.8% at n = 10 (3,598,696 against the true 3,628,800) and by about 0.16% at n = 52.

The error shrinks in relative terms as n grows, so it gets better exactly when exact arithmetic gets expensive.

What to take from it

The thing I'd keep is the shrinking-choices picture, not the formula. If you can see 5 slots with 5, 4, 3, 2, 1 options, you can rebuild n!, the permutation formula and “n choose k” from scratch, and you'll know why 0! has to be 1.

And you'll never trust a brute-force search over more than about a dozen items again. Go count something.

Sources and further reading

  1. 1.PrimaryWolfram MathWorld, "Factorial". Definition, the 1808 introduction of the n! notation by Christian Kramp, and the one-arrangement-of-zero-objects reason for 0! = 1.
  2. 2.ReportingWikipedia, "Factorial". History (Anuyogadvāra-sūtra, Bhāskara II in 1150, Stedman in 1677), the empty product, and the C(n, n) check on 0! = 1.
  3. 3.PrimaryNIST Digital Library of Mathematical Functions, §5.4 "Special Values and Extrema". Equation 5.4.1, n! = Γ(n + 1), and equation 5.4.6, Γ(1/2) = √π.
  4. 4.PrimaryNIST Digital Library of Mathematical Functions, §5.11 "Asymptotic Expansions". Stirling's series and formula for the gamma function, from which n! ≈ √(2πn)(n/e)ⁿ follows.
  5. 5.PrimaryGoogle Docs Editors Help, "FACT". Syntax, sample usage, and the silent truncation of a decimal input.
  6. 6.ReportingWikipedia, "Observable universe". The roughly 10⁸⁰ atom estimate (the Eddington number) and an age of 13.787 billion years.
  7. 7.PrimaryPython documentation, "math". math.gamma, math.lgamma, and the 3.10 change that stopped math.factorial accepting floats.

Frequently asked questions

What is a factorial in simple terms?
A factorial is the product of every whole number from 1 up to a given number. It is written with an exclamation mark, so 5! means 5 x 4 x 3 x 2 x 1, which is 120. It counts the number of ways to arrange that many distinct items in a row.
Why is 0 factorial equal to 1?
Zero factorial is 1 because there is exactly one way to arrange zero items, the empty arrangement, and because the product of no numbers is 1 by convention. It also keeps the rule n! = n x (n-1)! valid at n = 1, and it keeps the combinations formula working: choosing all 5 items from 5 gives 5! / (5! x 0!) = 1 only if 0! is 1.
How do you calculate a factorial?
Multiply the number by every whole number below it, down to 1. For 5! that is 5 x 4 x 3 x 2 x 1 = 120. A faster way is to build up: 1! = 1, 2! = 2 x 1 = 2, 3! = 3 x 2 = 6, 4! = 4 x 6 = 24, 5! = 5 x 24 = 120. In Google Sheets, type =FACT(5).
How big is 52 factorial?
52! is about 8.07 x 10^67, a 68-digit number, and it is the number of distinct orderings of a standard deck of cards. That is far larger than the roughly 4.4 x 10^17 seconds since the Big Bang, which is why a thoroughly shuffled deck has almost certainly never been in that order before.
Can you take the factorial of a negative number or a decimal?
Not with the basic definition, which only covers whole numbers 0 and up. The gamma function extends factorials to non-integers through n! = gamma(n + 1), so (1/2)! is about 0.8862 and (2.5)! is about 3.3234. The extension still breaks at negative whole numbers, where gamma has no value.
What are factorials used for?
Factorials count arrangements. n! counts orderings of n items, n! / (n-k)! counts ordered picks of k from n, and n! / (k! x (n-k)!) counts unordered picks, so choosing 3 of 5 gives 10. They also sit in the denominators of Taylor series, in the binomial and Poisson probability formulas, and in the worst-case O(n!) running time of brute-force search.

Written by

Tech Talk News Editorial

Computer engineering background. Writes about software, AI, markets, and real estate, and the places where the three meet.

More about the author
ShareXLinkedInRedditEmail