Menu

Factorial Calculator

Factorial Calculator: How It Works

The factorial of n is the product of every whole number from 1 to n. It counts the ways a set can be arranged, which is why it sits at the base of combinatorics and probability — and why it grows faster than almost any function you will meet.

Definition

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

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

By definition 0! = 1. This is not a convention adopted for convenience — there is exactly one way to arrange an empty set (do nothing), and the value keeps the recursive relation n! = n × (n−1)! consistent at n = 1.

How fast it grows

nn!
5120
103,628,800
151,307,674,368,000
202,432,902,008,176,640,000
25≈ 1.55 × 10²⁵
70≈ 1.20 × 10¹⁰⁰

Twenty is where a 64-bit signed integer overflows — 21! no longer fits. Seventy is roughly where a standard double-precision float gives up. A deck of 52 cards has 52! ≈ 8 × 10⁶⁷ possible orderings, which is more than the estimated number of atoms in our galaxy. Every properly shuffled deck has, with overwhelming probability, never existed before.

Permutations and combinations

FormulaOrder matters?
PermutationsP(n,r) = n! ÷ (n−r)!Yes
CombinationsC(n,r) = n! ÷ [r!(n−r)!]No

Choosing 3 people from 10 for specific roles of chair, secretary and treasurer is a permutation: 10! ÷ 7! = 720. Choosing 3 people for an unranked committee is a combination: 10! ÷ (3! × 7!) = 120. The factor of 6 between them is 3!, the number of ways to order any three chosen people.

This is exactly how lottery odds are computed. Choosing 6 numbers from 49 without regard to order gives C(49,6) = 13,983,816 possible tickets.

Where factorials appear

Beyond whole numbers

The gamma function extends factorials to non-integers, with Γ(n) = (n−1)! for positive integers. It gives meaning to expressions like (½)!, which equals √π ÷ 2 — a genuinely surprising result linking factorials to π, and one that appears throughout statistics.

Stirling's approximation

For large n, computing a factorial exactly becomes impractical, and Stirling's approximation gives a close estimate: n! ≈ √(2πn) × (n ÷ e)ⁿ. It is accurate to within about 1% by n = 10 and improves from there, which makes it standard in statistical mechanics and asymptotic analysis.

Frequently Asked Questions

Why does 0! equal 1?
There is exactly one way to arrange nothing — the empty arrangement. It also keeps the recursive definition n! = n × (n−1)! consistent at n = 1, and makes the combination formula work when choosing zero items.
Can I take the factorial of a negative number?
Not in the standard definition. The gamma function, which extends factorials to real and complex numbers, has poles at zero and the negative integers, so negative whole numbers have no factorial.
Why do calculators fail on large factorials?
The values grow beyond what standard number types can hold. A 64-bit integer overflows at 21!, and a double-precision float reaches its limit around 170!. Larger values need arbitrary-precision arithmetic.
What is the difference between a permutation and a combination?
Whether order matters. Permutations count arrangements, combinations count selections. Choosing 3 from 10 gives 720 permutations and 120 combinations — the difference is the 6 ways to order any 3 chosen items.
How are lottery odds calculated?
With the combination formula, since draw order does not matter. Choosing 6 from 49 gives C(49,6) = 13,983,816 possible tickets, so a single ticket has one chance in nearly 14 million.
Is there a factorial of a fraction?
Through the gamma function, yes. The factorial of one half equals √π ÷ 2 — a surprising link between factorials and π that appears throughout statistics and probability theory.

Related Calculators Tools

Browse all Calculators tools →