Factorial Calculator
Compute n! exactly, with the full expansion and step-by-step product
Last updated October 2026
Method: The standard definition n! = n × (n − 1) × … × 2 × 1, with 0! = 1, multiplied with arbitrary-precision BigInt arithmetic, so every digit is exact up to 20,000!. From 20,001! to 1,000,000! the leading digits come from Stirling's series (NIST DLMF §5.11) while the digit count and trailing zeros stay exact. Decimals return the gamma function value Γ(x + 1) (NIST DLMF §5.4).
Included: The exact value of n!, the number of digits, the number of trailing zeros, the expanded multiplication, and a step-by-step running product for n up to 12. Long results show a correctly rounded scientific-notation preview plus all exact digits on demand.
Not included: Double factorials (n!!), subfactorials, modular factorials and complex arguments. Negative whole numbers have no factorial, so the calculator explains why instead of showing a value.
❗ Enter a number
Exact to the last digit up to 20,000!, estimated up to 1,000,000!. A decimal such as 2.5 returns the gamma function value Γ(x + 1).
Result of 5!
✖️ Expanded multiplication
5! = 5 × 4 × 3 × 2 × 1 = 120📋 Step by step
| Step | Multiply by | Running product |
|---|---|---|
| 1 | × 1 | 1 |
| 2 | × 2 | 2 |
| 3 | × 3 | 6 |
| 4 | × 4 | 24 |
| 5 | × 5 | 120 |
Each step multiplies the running total by the next integer, finishing at 5!.
Factorial calculator: everything you need to know
A factorial calculator multiplies a whole number by every positive integer below it: n! = n × (n − 1) × … × 2 × 1. For example, 5! = 5 × 4 × 3 × 2 × 1 = 120. Enter any non-negative integer to get the exact value of n!, its digit count, its trailing zeros and the full expansion. Exact big-integer math keeps even enormous inputs like 100! (a 158-digit number) precise to the last digit.
Factorials are the building block of counting. To arrange or choose only some of the items, the Permutation & Combination Calculator divides the factorials for you; to turn those counts into odds, use the Probability Calculator; for the coefficients of (a + b)n, the Binomial Expansion Calculator; and for other numbers too long for an ordinary calculator, the Big Number Calculator.
What a factorial actually means
Imagine you have three different books and want to line them up on a shelf. The first slot can hold any of the 3 books, the second slot any of the remaining 2, and the last slot the final 1 book. Multiply those choices together (3 × 2 × 1) and you get 6 possible orderings. That product is exactly 3!. In general, n! counts the number of distinct ways to arrange n different items in a row. This is why factorials are the backbone of combinatorics: permutations and combinations, and the probability formulas built on them, all rest on top of the humble factorial.
The factorial formula and definition
The factorial of a non-negative integer n is the product of every whole number from 1 to n:
n! = n × (n − 1) × (n − 2) × … × 2 × 1 There is also a neat recursive definition that says each factorial is built from the one before it:
n! = n × (n − 1)! with 0! = 1 Both definitions produce identical results. The recursive form is handy in programming and proofs, while the spelled-out product is easier to picture. The crucial base case is 0! = 1: there is exactly one way to arrange nothing (do nothing), and that value keeps every formula built on factorials consistent.
Worked example: 5!
Let's compute 5! by hand, multiplying one step at a time:
- Start at 1.
- 1 × 2 = 2
- 2 × 3 = 6
- 6 × 4 = 24
- 24 × 5 = 120
So 5! = 120. That means five different items can be ordered in 120 distinct ways: the same number of ways five guests can be seated in a row, or five runners can finish a race.
Factorial step by step: computing 8! as a running product
This is exactly how the calculator works internally and how you would do it on paper: start at 1 and multiply by each integer in turn, carrying the running total forward.
| Step | Multiply | Running product |
|---|---|---|
| 1 | 1 × 1 | 1 |
| 2 | 1 × 2 | 2 |
| 3 | 2 × 3 | 6 |
| 4 | 6 × 4 | 24 |
| 5 | 24 × 5 | 120 |
| 6 | 120 × 6 | 720 |
| 7 | 720 × 7 | 5,040 |
| 8 | 5,040 × 8 | 40,320 |
After the final step the running product is 8! = 40,320. The same loop scales to any n: each row simply multiplies the previous total by the next integer. (For large n the calculator groups the same multiplications into a tree of partial products, which gives the identical result much faster.)
How to use this factorial calculator
You only need one number to get a complete answer. Here is the workflow:
- Enter n: type a non-negative whole number (for example 0, 7, 20, or 100) into the input box. A thousands separator such as 10,000 is fine.
- Read the result: the large blue number at the top is n!. Up to 30 digits it is shown in full with thousands separators; longer results show a scientific-notation preview rounded to 6 significant digits, next to the digit count and the number of trailing zeros.
- See the expansion: the "Expanded multiplication" card spells out n × (n − 1) × … × 1 so you can follow the logic.
- Follow the steps: for n up to 12, the step-by-step table shows the running product after each multiplication, mirroring how you would do it on paper.
- Expand huge results: when a factorial has hundreds of digits, open the "Show all digits" panel to reveal the exact integer.
The result updates instantly as you type; there is no "calculate" button to press. Use the quick-pick chips (0!, 5!, 10!, 13!, 20!, 52!, 100! and 1000!) to jump to common values. If you type a decimal such as 2.5, the calculator explains that factorials need whole numbers and shows the gamma function value Γ(3.5) instead.
Who this calculator is for
Factorials sit at the crossroads of school math and real-world counting problems, so this tool serves a wide audience:
- Students learning combinatorics, probability, or the binomial theorem who need to check homework.
- Teachers who want a clean expansion to project or share when introducing permutations.
- Programmers verifying a factorial function or testing against an exact reference value.
- Statisticians and data scientists computing permutations, combinations, or Poisson-style terms by hand.
- Anyone curious about just how fast factorials explode: try 70! and watch the digit count climb past 100.
Worked example: 10! and a permutation
Computing 10! gives 3,628,800, the number of ways to order ten distinct items. Now suppose you only care about arranging 3 of those 10 items in order. That is a permutation, written P(10, 3), and it equals 10! / (10 − 3)! = 10! / 7! = 3,628,800 / 5,040 = 720. Notice how the factorial does the heavy lifting: you compute the full count and then divide away the orderings you do not care about. The same idea drives combinations, where you divide by an extra factorial to ignore order entirely. If you need those counts directly, the Permutation & Combination Calculator does the division for you.
Factorials behind common permutations and combinations
Most real counting problems are permutations P(n, r) = n! / (n − r)! (order matters) or combinations C(n, r) = n! / (r! × (n − r)!) (order does not). Both are just factorials divided by factorials. This table shows the exact counts for cases people look up most.
| Problem | n, r | Permutations P(n, r) | Combinations C(n, r) |
|---|---|---|---|
| Order 3 of 10 items | 10, 3 | 720 | 120 |
| Pick 5 of 10 items | 10, 5 | 30,240 | 252 |
| First & second of 20 | 20, 2 | 380 | 190 |
| Arrange 4 of 15 | 15, 4 | 32,760 | 1,365 |
| 6/49 lottery draw | 49, 6 | 10,068,347,520 | 13,983,816 |
| 5-card poker hand | 52, 5 | 311,875,200 | 2,598,960 |
Every value here comes straight from factorials: for the 5-card poker hand, C(52, 5) = 52! / (5! × 47!) = 2,598,960 possible hands.
Worked example: a huge factorial
Enter 52 and you get the number of ways to shuffle a standard deck of cards: 52! ≈ 8.07 × 10^67 (8.06582 × 10^67 to six digits), a 68-digit number. That figure is so vast that a thoroughly shuffled deck is almost certainly in an order no deck has ever been in before. Push to 100! and the result has 158 digits, the last 24 of them zeros. Ordinary calculators give up or round here, but this tool keeps every digit because it uses arbitrary-precision integers; expand the digits panel to see all 158 of them.
How many digits does a large factorial have?
For big inputs the exact integer is impractical to read, so the useful facts are its digit count and its scientific-notation form. This table lists both for the values people search for most, from 20! to 1000!, rounded to three significant digits.
| n | Digits in n! | n! (scientific notation) |
|---|---|---|
| 20 | 19 | 2.43 × 10^18 |
| 25 | 26 | 1.55 × 10^25 |
| 30 | 33 | 2.65 × 10^32 |
| 40 | 48 | 8.16 × 10^47 |
| 50 | 65 | 3.04 × 10^64 |
| 52 | 68 | 8.07 × 10^67 |
| 60 | 82 | 8.32 × 10^81 |
| 70 | 101 | 1.20 × 10^100 |
| 80 | 119 | 7.16 × 10^118 |
| 90 | 139 | 1.49 × 10^138 |
| 100 | 158 | 9.33 × 10^157 |
| 170 | 307 | 7.26 × 10^306 |
| 200 | 375 | 7.89 × 10^374 |
| 500 | 1,135 | 1.22 × 10^1134 |
| 1000 | 2,568 | 4.02 × 10^2567 |
Around n = 170 a standard double-precision float overflows to infinity, since 171! (about 1.24 × 10^309) exceeds the largest representable double, about 1.8 × 10^308. That is the point where you must switch to big-integer or log-based math. This calculator does both: BigInt for exact values up to 20,000!, and the log-gamma function for the estimates beyond.
Factorial reference table
Here are the factorials of 0 through 20, a handy reference for spot-checking and seeing how quickly they grow:
| n | n! |
|---|---|
| 0 | 1 |
| 1 | 1 |
| 2 | 2 |
| 3 | 6 |
| 4 | 24 |
| 5 | 120 |
| 6 | 720 |
| 7 | 5,040 |
| 8 | 40,320 |
| 9 | 362,880 |
| 10 | 3,628,800 |
| 11 | 39,916,800 |
| 12 | 479,001,600 |
| 13 | 6,227,020,800 |
| 14 | 87,178,291,200 |
| 15 | 1,307,674,368,000 |
| 16 | 20,922,789,888,000 |
| 17 | 355,687,428,096,000 |
| 18 | 6,402,373,705,728,000 |
| 19 | 121,645,100,408,832,000 |
| 20 | 2,432,902,008,176,640,000 |
Notice that 13! already exceeds 6 billion, and by 20! the value passes 2.4 quintillion. This explosive growth is why factorials outrun exponential functions and why even modest inputs need big-integer math.
Key terms explained
- Factorial (n!): the product of all positive integers up to n; counts orderings of n items.
- Permutation P(n, r): the number of ordered arrangements of r items from n, equal to n! / (n − r)!.
- Combination C(n, r): the number of unordered selections of r from n, equal to n! / (r! × (n − r)!).
- Gamma function Γ: a continuous extension of the factorial where Γ(n + 1) = n!, defined for non-integers too.
- Double factorial (n!!): the product of integers with the same parity as n (for example 7!! = 7 × 5 × 3 × 1); a different operation from the ordinary factorial.
- Stirling's approximation: a formula, n! ≈ √(2πn) (n/e)^n, that estimates large factorials without multiplying every term.
Why factorials grow so fast
Each step in a factorial multiplies by a larger number than the last, so the value compounds at an ever-increasing rate. An exponential like 2^n multiplies by the same factor (2) each step; a factorial multiplies by n, n − 1, n − 2 and so on. That is why n! eventually overtakes any fixed-base exponential and why the number of digits climbs steeply. Stirling's approximation captures this: it shows the digit count grows roughly in proportion to n log n, which is why 100! lands at 158 digits and 1000! at over 2,500.
Where factorials show up
Beyond textbook exercises, factorials appear constantly:
- Card games and shuffling: 52! is the number of possible deck orders.
- Probability and odds: permutations and combinations, both built on factorials, count favorable and total outcomes.
- The binomial theorem: binomial coefficients "n choose r" use factorials to expand (a + b)^n.
- Calculus and series: Taylor series for sine, cosine and e^x divide each term by a factorial.
- Algorithms: the brute-force cost of checking every ordering (such as every route in the traveling-salesman problem) grows like n!.
Tips for working with factorials
- Cancel before you multiply: in expressions like 10! / 7!, cancel the shared terms (10! / 7! = 10 × 9 × 8 = 720) instead of computing both factorials.
- Remember 0! = 1 and 1! = 1: these base cases trip up many beginners.
- Use exact arithmetic: ordinary double-precision numbers hold n! exactly only through 22! and round the trailing digits from 23! on; this calculator's BigInt math does not.
- Estimate with Stirling: when you only need the rough size or digit count, Stirling's approximation is faster than the full product.
How it compares to related calculators
This page answers "what is n!?" If your question is a bit different, a sister tool fits better:
- To count ordered or unordered selections directly (nPr and nCr), use the Permutation & Combination Calculator.
- To turn those counts into odds and chances, use the Probability Calculator.
- To raise a number to a power, use the Exponent Calculator.
- To expand (a + b)n with its binomial coefficients, use the Binomial Expansion Calculator.
- For exact arithmetic on other very long numbers, use the Big Number Calculator.
- For another fast-growing integer sequence, see the Fibonacci Calculator.
- To write a giant factorial like 100! in the form a × 10b, use the Scientific Notation Calculator.
- For trig, logs and general expressions, use the Scientific Calculator.
Factorials in computing and notation
Factorials are a favorite teaching example in programming because they show off two ideas at once: iteration (a loop that multiplies a running total by 1, 2, 3, …, n) and recursion (a function that calls itself with n − 1 until it hits the base case 0! = 1). The catch is size. A standard 64-bit integer overflows at 21!, and a double-precision floating-point number stops being exact at 23! (it holds 22! exactly only because factorials end in many binary zeros), so any serious factorial routine needs arbitrary-precision (big-integer) arithmetic, which is exactly what this calculator uses under the hood. When a result has too many digits to read comfortably, it is conventional to write it in scientific notation, for example 100! ≈ 9.33 × 10157, while keeping the full exact integer available on demand.
A quick note on notation you may meet alongside the plain factorial. The double factorial n!! multiplies only every second term down from n (so 8!! = 8 × 6 × 4 × 2 = 384), which is a different operation, not "the factorial of a factorial." The subfactorial !n counts derangements (permutations where nothing stays in its original place), and the falling factorial appears in the permutation formula. All of these descend from the same counting idea, but only the ordinary single factorial is what this page computes.
Frequently asked quick facts
- What is 5! ? 5! = 120.
- What is 6! ? 6! = 720.
- What is 10! ? 10! = 3,628,800.
- What is 12! ? 12! = 479,001,600, the largest factorial that still fits in a 32-bit signed integer.
- What is 13! ? 13! = 6,227,020,800, the first factorial that overflows a 32-bit integer.
- What is 0! ? 0! = 1, by definition.
- What is 1! ? 1! = 1.
- How many digits does 100! have? 158 digits, ending in 24 zeros.
- What is 0.5! ? Not an ordinary factorial; the gamma function gives Γ(1.5) = √π ÷ 2 ≈ 0.886227.
These are the values people most often look up, and they double as a fast sanity check: a tool that returns 0 for 0! has the definition wrong, and one that rounds the trailing digits of 25! is using floating-point math rather than the exact big-integer arithmetic this calculator relies on.
Sources & further reading
- NIST Digital Library of Mathematical Functions, §5.4 Special Values and Extrema: n! = Γ(n + 1) (5.4.1) and Γ(1/2) = √π (5.4.6).
- NIST Digital Library of Mathematical Functions, §5.2 Definitions: the gamma function has simple poles at z = 0, −1, −2, …, which is why negative whole numbers have no factorial.
- NIST Digital Library of Mathematical Functions, §5.11 Asymptotic Expansions: Stirling's series for ln Γ(z), used for the estimates above 20,000!, and Stirling's formula n! ≈ √(2πn) (n/e)n.
- ECMAScript Language Specification, §6.1.6.2 The BigInt Type (integers of any size) and §21.1.2.7 Number.MAX_VALUE (about 1.8 × 10308, the reason ordinary numbers overflow after 170!).
⚠️ Common mistakes & edge cases
Thinking 0! = 0
A common slip is assuming the factorial of zero is zero. It is not: 0! = 1 by definition, because there is exactly one way to arrange nothing, and it keeps the recurrence n! = n × (n − 1)! consistent.
Trying to take the factorial of a decimal or negative
The ordinary factorial is only defined for non-negative whole numbers. There is no plain factorial of 2.5 or −3. For 2.5 the calculator shows the gamma function value Γ(3.5) ≈ 3.3234 and labels it as such; for −3 there is no value at all, because the gamma function has poles at the negative whole numbers.
Trusting a standard calculator for large n
From 23! on, ordinary floating-point numbers can no longer store the result exactly and start rounding the trailing digits. If you need every digit (for example checking a programming result), use exact BigInt math like this tool does.
Confusing n! with n!! or with permutations
The double factorial n!! multiplies only the same-parity terms (7!! = 7 × 5 × 3 × 1), and a permutation P(n, r) arranges just r of the n items. Both are related to, but different from, the ordinary factorial.
❓ Frequently asked questions
What is a factorial?
The factorial of a non-negative integer n, written n!, is the product of every whole number from 1 up to n. For example, 5! = 5 × 4 × 3 × 2 × 1 = 120. It counts the number of distinct ways to arrange n different items in order, which is why factorials appear throughout combinatorics, probability and statistics.
Why is 0! equal to 1?
By definition, 0! = 1. There is exactly one way to arrange zero items (the empty arrangement), so the count is 1. It also makes formulas consistent: the recurrence n! = n × (n − 1)! gives 1! = 1 × 0!, which only works if 0! = 1. The same value keeps the binomial-coefficient and series formulas that rely on factorials from breaking down.
Can you take the factorial of a negative number or a fraction?
The ordinary factorial is only defined for non-negative integers (0, 1, 2, 3, …). Mathematicians extend it with the gamma function, where n! = Γ(n + 1) for whole numbers (NIST DLMF 5.4.1). The gamma function has values between the whole numbers, so this calculator shows Γ(x + 1) when you enter a decimal such as 2.5 and labels it as a gamma value. Negative whole numbers have no factorial at all, because the gamma function has poles at 0, −1, −2, …
What is 0.5 factorial?
0.5! is not an ordinary factorial, but the gamma function gives it a value: 0.5! = Γ(1.5) = √π ÷ 2 ≈ 0.886227. It follows from Γ(1/2) = √π (NIST DLMF 5.4.6) and the rule Γ(x + 1) = x × Γ(x). In the same way (−0.5)! = Γ(0.5) = √π ≈ 1.772454 and 2.5! = Γ(3.5) ≈ 3.323351. Type any of these decimals into the calculator to see the value.
How big does a factorial get?
Factorials grow faster than exponentials. 10! is already 3,628,800; 20! is about 2.43 × 10^18; and 100! has 158 digits. They quickly exceed what standard floating-point numbers can store exactly, which is why this calculator uses arbitrary-precision (BigInt) arithmetic to keep every digit correct.
How is the factorial calculated?
You start with 1 and multiply by each integer in turn: 1 × 2 × 3 × … × n. Equivalently, you can use the recursive rule n! = n × (n − 1)! with the base case 0! = 1. Both give the same result. For speed, this tool multiplies the numbers in a balanced tree of partial products, which gives the identical exact value much faster for large n, and it shows the running product for n up to 12.
What is the difference between a factorial and a permutation?
A factorial n! counts the arrangements of all n items. A permutation P(n, r) = n! / (n − r)! counts the ordered arrangements of just r items chosen from n. So a factorial is the special case of a permutation where you arrange every item (r = n).
Why are factorials used in probability?
Many probability questions reduce to counting arrangements or selections. Factorials are the building block for permutations (ordered) and combinations (unordered), which in turn give the number of possible outcomes. For example, the number of 5-card poker hands from a 52-card deck is 52! / (5! × 47!) = 2,598,960.
Does this calculator give an exact answer for large n?
Yes, up to 20,000!. It computes with BigInt, so the result is the exact integer no matter how many digits it has (20,000! has 77,338). Results longer than 30 digits are previewed in scientific notation, rounded to 6 significant digits, and one click shows every digit of the exact value. From 20,001! to 1,000,000! the leading digits are estimated with Stirling's series, while the digit count and the number of trailing zeros stay exact.
What is the largest number I can enter?
Exact results go up to n = 20,000, which takes a few hundredths of a second in a typical browser. Estimates go up to n = 1,000,000, whose factorial has 5,565,709 digits. Beyond that, even writing out the digit count is of little practical use, so the calculator stops there.
How many zeros are at the end of 100!?
100! ends in 24 zeros. Each trailing zero needs a factor of 10 = 2 × 5, and factors of 2 are plentiful, so you only count the factors of 5: 100 ÷ 5 = 20 multiples of 5, plus 100 ÷ 25 = 4 multiples of 25 that contribute a second 5, for 20 + 4 = 24. By the same rule 1000! ends in 200 + 40 + 8 + 1 = 249 zeros. The calculator shows this count for every n.
What does the exclamation point mean in math?
In mathematics, the exclamation point after a number means factorial. So 5! is read as "five factorial" and equals 120. It is not an expression of emphasis but a standard operator that tells you to multiply the number by every positive integer below it.
Why does a factorial overflow a 32-bit integer at 13?
A 32-bit signed integer can hold values up to about 2.1 billion. 12! = 479,001,600 still fits, but 13! = 6,227,020,800 exceeds that limit and overflows. A 64-bit integer stretches the limit to 20!, and 21! overflows that too. This is why exact factorial code needs arbitrary-precision (big-integer) arithmetic, which is what this calculator uses.
How do you write a factorial in programming?
Two approaches are common. An iterative version starts a running product at 1 and multiplies by each integer from 2 to n in a loop. A recursive version defines factorial(n) as n times factorial(n − 1), with the base case factorial(0) = 1. Both are correct; the iterative form avoids deep recursion. In JavaScript, ordinary numbers hold n! exactly only through 22! and round the trailing digits from 23! on, so use BigInt for exact results.
What is 100 factorial (100!)?
100! is approximately 9.33 × 10^157, an exact integer with 158 digits that ends in 24 zeros. It is the number of ways to arrange 100 distinct items in order. No standard calculator or 64-bit number can hold it exactly; this tool computes it with arbitrary-precision arithmetic and can show all 158 digits on demand.
How many digits does 1000! have?
1000! has 2,568 digits and is approximately 4.02 × 10^2567. Because factorials grow faster than exponentials, the digit count climbs steeply: 100! has 158 digits, 500! has 1,135, and 1000! has 2,568. This calculator reports the exact digit count even when the full number is too long to read.
💡 Good to know
The exclamation point is the factorial operator
In math, "5!" does not mean shouting: it is read "five factorial" and equals 120. The symbol was introduced in the early 1800s and has been the standard notation ever since.
Factorials beat exponentials
For large enough n, n! grows faster than any fixed-base exponential like 2^n or 10^n. Checking every ordering of just 20 items means 20! ≈ 2.4 × 1018 cases, which would keep a computer doing a billion checks per second busy for about 77 years.
Exact to the last digit
Because this calculator uses arbitrary-precision integers, the result is exact no matter how many digits it has: 100! is shown with all 158 digits intact, not rounded, and so is every factorial up to 20,000!.
Related Calculators
Permutation & Combination Calculator
Calculate nPr and nCr
Probability Calculator
Calculate the probability of events
Binomial Expansion Calculator
Expand (a + b)^n with the binomial theorem
Big Number Calculator
Exact arithmetic on very large numbers
Scientific Notation Calculator
Convert numbers to and from scientific notation
Exponent Calculator
Raise numbers to any power
Fibonacci Calculator
Generate the Fibonacci sequence and the nth term
Scientific Calculator
A full scientific calculator with trig, logs and more