How Factorials Work (And How to Calculate n!)

Learn what n! means, why 0! = 1, how factorials drive permutations, how fast they grow, and how to calculate them with clear steps.

By Generatr Team

The factorial of a non-negative integer n, written n!, multiplies every positive integer up to n: 5! = 5 × 4 × 3 × 2 × 1 = 120. Factorials count how many ways you can order n distinct objects and show up throughout permutations, series, and probability models.

This guide covers the definition, why 0! equals 1, the link to permutations, how fast factorials grow, and practical calculation tips including trailing zeros. For exact values and step-by-step expansion — including large n with BigInt-style results — open the free factorial calculator.

You will leave able to compute small n by hand, interpret 0!, and know when to switch from multiplication tables to a dedicated tool.

Free tool

Use the Factorial Calculator now

Open the interactive factorial calculator in your browser — free, instant, no signup.

Open Factorial Calculator

What Is a Factorial?

For a positive integer n:

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

You can also define factorials recursively: n! = n × (n − 1)! with a base case at 0! or 1!.

Small values to memorize

  • 1! = 1
  • 2! = 2
  • 3! = 6
  • 4! = 24
  • 5! = 120
  • 6! = 720
  • 7! = 5,040
  • 10! = 3,628,800

Worked expansion for 7!: 7 × 6 = 42; ×5 = 210; ×4 = 840; ×3 = 2,520; ×2 = 5,040; ×1 = 5,040.

Factorials are defined for non-negative integers in everyday school math. Extending to non-integers uses the gamma function (Γ(n+1) = n!), which is beyond most intro courses but explains why calculators sometimes accept 4.5! style input.

Practice expansions in the free factorial calculator when you want the multiplication written out and digit counts for larger n.

Why Is 0! Equal to 1?

0! = 1 by definition, and the choice keeps formulas consistent.

Empty product

Multiplying no numbers together is the empty product, which is taken to be 1 — the multiplicative identity. There is one way to arrange zero objects: do nothing.

Recursive consistency

From n! = n × (n − 1)!, set n = 1: 1! = 1 × 0! ⇒ 1 = 1 × 0! ⇒ 0! = 1.

Binomial coefficients

C(n, 0) = n! / (0! × n!) = 1. That matches the combinatorial fact that there is one way to choose nothing from a set. If 0! were 0, every binomial coefficient with a 0! in the denominator would break.

Students sometimes feel 0! “should” be 0 because multiplication by zero is familiar. Factorial is not “multiply zeros”; it is a counting product with an agreed empty case.

How Do Factorials Connect to Permutations?

If you have n distinct books and line them all up, the number of orders is n!. First position: n choices; second: n − 1; …; last: 1. Multiply to get n!.

  • 3 distinct medals: 3! = 6 finishing orders
  • 5 playlist tracks (all different): 5! = 120 play orders
  • 10 unique runners: 10! = 3,628,800 finish sequences

When you only arrange k out of n distinct items (order matters), the count is the permutation:

P(n, k) = n! / (n − k)!

Example: P(10, 3) = 10! / 7! = 10 × 9 × 8 = 720 (the extra factors in 7! cancel).

Combinations (order does not matter) divide by k! as well: C(n, k) = n! / (k!(n − k)!). Full workflows live in the permutation and combination guide and the permutation combination calculator.

Probability models that assume equally likely orderings use these counts as denominators — see the probability calculator guide when you move from pure counting to chance.

How Fast Do Factorials Grow?

Factorials grow faster than exponential functions with a fixed base once n is large enough. Compare rough magnitudes:

  • 10! ≈ 3.6 × 10⁵
  • 20! ≈ 2.4 × 10¹⁸
  • 50! ≈ 3.0 × 10⁶⁴
  • 100! has 158 digits

Powers like 2ⁿ grow quickly, but n! multiplies by a rising factor each step, so it overtakes fixed-base exponentials. Stirling’s approximation estimates ln(n!) for analysis and huge n without writing every digit:

n! ≈ √(2πn) × (n/e)ⁿ

Hand calculation stops being fun long before 100!. Phone calculators overflow ordinary floating-point around 170! in IEEE doubles. Exact integer tools use BigInt or arbitrary precision — Generatr’s factorial calculator is built for exact results far past pocket-calculator limits, with digit counts so you can see growth without scrolling a wall of digits blindly.

Powers and roots without the factorial product pattern still use the power calculator and the powers guide.

What Are Trailing Zeros, Double Factorials, and Subfactorials?

Trailing zeros in n! (in base 10) come from factors of 10 = 2 × 5. There are usually more factors of 2 than 5, so the count of times 5 divides n! is the standard formula:

zeros = ⌊n/5⌋ + ⌊n/25⌋ + ⌊n/125⌋ + …

  • 10! = 3,628,800 → 2 trailing zeros (⌊10/5⌋ = 2)
  • 25! → ⌊25/5⌋ + ⌊25/25⌋ = 5 + 1 = 6 trailing zeros

You can answer “how many zeros?” without writing the full factorial — useful on contests.

Related functions some calculators include

  • Double factorial n!! — product of every other integer down from n (parity-preserving). Example: 5!! = 5 × 3 × 1 = 15; 6!! = 6 × 4 × 2 = 48.
  • Subfactorial !n — number of derangements (permutations with no fixed points). Example: !3 = 2.

These variants share factorial DNA but answer different counting questions. Use them only when a problem statement asks for n!! or derangements explicitly.

How Do You Calculate n! by Hand and With a Tool?

For small n, multiply in order or use a known table. For large n, use exact arithmetic software or a browser calculator that supports big integers.

  1. Open the free factorial calculator.
  2. Enter a non-negative integer n.
  3. Choose standard n! (or double/subfactorial if your problem needs them).
  4. Read the exact value, expansion steps if shown, and digit count.
  5. Check trailing zeros when the question only needs zeros, not the full number.
  6. Copy the result into homework, code comments, or probability setups.

Hand tips

  • Pair factors to simplify (for example in 10!, group 10×9×8×7 then multiply by 6! if you know 720).
  • Cancel factorials in fractions early: 8!/6! = 8 × 7.
  • Never compute full n! if the problem only needs P(n, k) = n × (n−1) × … × (n−k+1).

Pair counting tools with the permutation combination calculator and chance questions with the probability calculator so you do not expand huge intermediates you will cancel later.

What Mistakes Happen With Factorials?

Common errors to avoid:

  • Writing n! = n × n — that is n², not n!
  • Setting 0! = 0 — it is 1
  • Applying factorial to each term of a sum — (a+b)! ≠ a! + b!
  • Forgetting order in “arrangements” — if order matters use permutations; if not, combinations
  • Overflowing ordinary calculators without noticing scientific notation or errors past ~170!
  • Counting trailing zeros by eye on a rounded display — use the factor-of-5 formula on the exact integer

This guide is educational. Competitive programming, CAS systems, and research use additional libraries for huge n and gamma-function extensions. For class and everyday counting, n!, 0!, and P(n, k) cover most needs.

Step-by-Step Instructions

  1. 1Open the free factorial calculator on Generatr.
  2. 2Enter a non-negative integer n.
  3. 3Compute n! as n × (n − 1) × … × 1 (with 0! defined as 1).
  4. 4Use the recursive check n! = n × (n − 1)! for small verification.
  5. 5For permutations of all n items, use n! as the count of orderings.
  6. 6For P(n, k), prefer n × (n−1) × … × (n−k+1) or n! / (n−k)!.
  7. 7For trailing zeros in base 10, sum ⌊n/5⌋ + ⌊n/25⌋ + ⌊n/125⌋ + …
  8. 8Switch to exact big-integer output when n grows past pocket-calculator range.

Frequently Asked Questions

How do you calculate n factorial?+

Multiply all positive integers from 1 through n. Example: 6! = 6 × 5 × 4 × 3 × 2 × 1 = 720. By definition, 0! = 1.

Why is 0! equal to 1?+

It is the empty product (equal to 1), it keeps the rule n! = n × (n − 1)! consistent at n = 1, and it makes binomial coefficients like C(n, 0) = 1 work correctly.

How are factorials used in permutations?+

The number of ways to order n distinct objects is n!. The number of ways to order k out of n is P(n, k) = n! / (n − k)!.

How fast do factorials grow?+

Very quickly: 10! is about 3.6 million, 20! is about 2.4×10¹⁸, and 100! has 158 digits. They eventually outpace fixed-base exponentials like 2ⁿ.

How many trailing zeros does 25! have?+

Count factors of 5: ⌊25/5⌋ + ⌊25/25⌋ = 5 + 1 = 6 trailing zeros in base 10.

Is Generatr’s factorial calculator free?+

Yes. Compute n!, related variants, expansions, digit counts, and trailing zeros in your browser with exact big-integer support — no account required.

Ready to try it yourself?

Use the free Factorial Calculator — no download, no account.

Launch Factorial Calculator