Factorial Calculator
For any whole number n from 0 to 170 this calculator multiplies every integer down to 1 and prints the exact result. As an example, 10! = 3,628,800, a number with 7 digits and no trailing zeros.
| n factorial, exact | |
| Digit count | |
| Trailing zeros | |
| Last non-zero digit | |
| Ways to arrange n items | |
| The multiplication itself |
The exact value uses big integer arithmetic, so every digit is real. Trailing zeros are counted from the factors of 5 below n. All calculations run in your browser, and nothing you type is uploaded or stored.
Enter a whole number up to 170 to get the exact factorial, its digit count, trailing zeros and last non-zero digit.
Key takeaways
- 5! = 120 counts the ways to order 5 items, and each factorial is just the previous one times the next n
- 0! = 1 because there is one way to arrange nothing: leave the shelf empty
- 100! ends in 24 zeros, found by counting fives: floor(100/5) + floor(100/25)
- 10! = 3,628,800 and 20! = 2,432,902,008,176,640,000
- 170! is the last factorial a standard calculator number can hold; 171! overflows
On this page
What a factorial counts
A factorial asks how many ways you can line up a set of items with nothing left over. Written with an exclamation mark, n factorial means multiply every whole number from n down to 1: 5 factorial is 5 x 4 x 3 x 2 x 1 = 120. So five books can be arranged on a shelf 120 different ways, and that physical picture is the whole idea.
Each factorial also builds on the one below it. Put a sixth book on the shelf and it can slot into any of 6 positions next to each of the 120 arrangements, giving 6 x 120 = 720. That recursion, n! = n x (n - 1)!, is why factorials grow so fast: every step multiplies by something bigger than the last step did. The Britannica entry on factorials traces how the notation spread through probability work in the 1800s.
The calculator on this page takes any whole number from 0 to 170 and returns the exact product using big integer arithmetic, so nothing is rounded. It also reports the digit count, the number of trailing zeros, the last non-zero digit, and the same value restated as the number of ways to arrange n items.
The factorials worth knowing on sight
Most everyday questions involve small factorials, and these twelve cover nearly all of them:
| n | n! exact value | A way to picture it |
|---|---|---|
| 0 | 1 | one way to arrange nothing |
| 1 | 1 | one item, one order |
| 2 | 2 | AB or BA |
| 3 | 6 | ABC, ACB, BAC, BCA, CAB, CBA |
| 4 | 24 | 4 people in a photo line |
| 5 | 120 | 5 books on a shelf |
| 6 | 720 | 6 runners in lane order |
| 7 | 5,040 | 7 days of unique meal plans |
| 8 | 40,320 | 8 dancers in formation |
| 9 | 362,880 | 9 players batting orders |
| 10 | 3,628,800 | 10 digits, each used once |
| 11 | 39,916,800 | 11 soccer starters |
| 12 | 479,001,600 | a year of hours, arranged |
Notice the jump from row to row: multiply each value by the next n and you land on the row below. 10! passes three million, 13! passes six billion, and by 20! the value is 2,432,902,008,176,640,000, a number past two quintillion. Growth this steep is why a rough sense of the small rows pays off when you sanity check a big answer.
Trailing zeros without multiplying anything
Every trailing zero in n! comes from a factor of 10, and every 10 comes from a 2 paired with a 5. Twos are plentiful, so the fives control the count. Count the multiples of 5 up to n, then the multiples of 25 (each donates a second five), then 125, and so on. Add those up and you have the zeros. The formula is sum of floor(n/5^k) for k = 1, 2, 3 until the floor hits zero.
Two checks show it working. For 100!: floor(100/5) = 20 and floor(100/25) = 4, so 20 + 4 = 24 trailing zeros. For 1000!: floor(1000/5) = 200, floor(1000/25) = 40, floor(1000/125) = 8, floor(1000/625) = 1, and 200 + 40 + 8 + 1 = 249. The MathWorld factorial reference covers this count under Legendre's formula, and the widget on this page computes it the same way, so you can cross check any n by hand in a few lines.
The same logic explains why the count jumps at multiples of 5 and leaps again at multiples of 25. Between 24! and 25! the trailing zeros go from 4 to 6, because 25 supplies two fives at once.
| n | Zeros in n! |
|---|---|
| 10 | 2 |
| 25 | 6 |
Worked examples: arranging and picking
Factorials answer arrangement questions directly, and combination questions after one division:
- Anagrams of STATISTICS. The word has 10 letters with S appearing 3 times, T 3 times and I twice, so the count is 10! / (3! x 3! x 2!) = 3,628,800 / 72 = 50,400 distinct anagrams.
- A three person committee from nine volunteers. Order does not matter here, so the count is 9! / (3! x 6!) = 84 committees.
- Picking 6 numbers in a 49 number lottery. 49! / (6! x 43!) = 13,983,816 possible tickets, which is why the jackpot odds are so long.
- Five card hands from a 52 card deck. 52! / (5! x 47!) = 2,598,960 hands.
The pattern in every line is the same: count the full arrangements with n!, then divide out the order you promised to ignore. When a problem says "how many ways" and order matters, stop at the factorial; when order does not matter, divide by the factorial of the group size. The NIST DLMF section on combinatorics formalizes both counts.
How big factorials get before computers give up
Ordinary calculator numbers, called double precision floats, hold values up to about 1.8 x 10^308. Factorial crosses that line between 170 and 171: 170! is about 7.257 x 10^306 and 171! is about 1.25 x 10^309, too large to store. That is the reason this calculator stops at 170, and why many tools report an overflow error past that point instead of a number.
Precision runs out even earlier. A double keeps roughly 15 to 17 significant digits, so n! is stored exactly only up to 22!, after which the calculator shows a rounded scientific form. 20! at 2,432,902,008,176,640,000 has 19 digits and survives intact, but 25! already loses digits that a big integer keeps. The widget here sidesteps the ceiling with JavaScript BigInt values and can print every digit of 170! (all 307 of them) if you ask for it.
For a sense of scale without printing: 50! has 65 digits, 100! has 158 digits and 170! has 307. A rough mental estimate comes from the multiplication itself: each new factor adds a little under one digit per step once n passes the low teens.
Factorials in probability and sampling
Factorials appear whenever a problem counts choices in stages. If order matters, start with a factorial: the number of ways to choose and arrange r items from n is n! divided by (n - r)!. If order does not matter, divide once more by r!, giving the combination formula n! / (r! x (n - r)!). The distinction is practical: a podium with gold, silver and bronze has ordered outcomes, while a three-person committee does not.
| Question | Formula | Example |
|---|---|---|
| Arrange all n items | n! | 5! = 120 |
| Arrange r of n | n! / (n-r)! | 5P2 = 20 |
| Choose r of n | n! / (r!(n-r)!) | 5C2 = 10 |
| Situation | Order matters? | Use |
|---|---|---|
| Podium finishers | Yes | Permutation |
| Committee members | No | Combination |
For a card hand, committee or lottery selection, combinations prevent counting the same group repeatedly in different orders. For a race, seating chart or password positions, permutations preserve order. Writing down that decision before reaching for a formula is often more important than the arithmetic itself. The calculator supplies the factorial values; the model tells you which values belong in the numerator and denominator.
Why 0! is 1 and other edge cases
The strangest entry in the table, 0! = 1, follows from the arrangement picture: there is exactly one way to arrange an empty shelf, which is to leave it as it is. The recursion agrees, because n! = n x (n - 1)! only stays consistent if 1! = 1 x 0!, which forces 0! = 1. Formally it is the empty product, the multiplicative version of starting a sum at zero.
Three edge cases cause most of the trouble:
- Negative numbers and fractions have no factorial. The definition only runs over descending whole numbers. (A separate function, the gamma function, extends the idea to decimals, but that is a different tool.)
- Factorials do not split over multiplication: 3! x 4! = 6 x 24 = 144, while 7! = 5,040. The tempting shortcut (7! = 3! x 4!) fails by a factor of 35.
- Addition stays outside: (2 + 3)! = 5! = 120, not 2! + 3! = 8.
A quick habit that catches most slips: recompute a known row. If your answer for 6! is not 720, something upstream went wrong.
Frequently asked questions
What is 5 factorial?
5! = 5 x 4 x 3 x 2 x 1 = <strong>120</strong>. It counts the ways to order 5 items, like 5 books on a shelf.
Why is 0 factorial equal to 1?
There is exactly one way to arrange zero items: the empty arrangement. The recursion n! = n x (n - 1)! also forces it, since 1! = 1 x 0! and 1! = 1.
How many trailing zeros does 100 factorial have?
<strong>24</strong>. Count fives: 20 multiples of 5 plus 4 multiples of 25 gives 24 factors of 10, so 100! ends in 24 zeros.
How many zeros end 1000 factorial?
<strong>249</strong>: floor(1000/5) = 200, plus floor(1000/25) = 40, plus floor(1000/125) = 8, plus floor(1000/625) = 1.
What is the largest factorial a regular calculator can hold?
170!, about 7.257 x 10^306 with 307 digits. 171! is about 1.25 x 10^309, which overflows the double precision limit of about 1.8 x 10^308.
What is 10 factorial?
3,628,800. It counts the ways to arrange 10 items, and it is also the number of distinct 10 digit strings that use each digit 0 through 9 once.
What is 20 factorial?
20! = <strong>2,432,902,008,176,640,000</strong>, a 19 digit number just past two quintillion. It is the last factorial a double stores with every digit exact.
Can you take the factorial of a negative number or a decimal?
No. The definition multiplies descending whole numbers, so it only exists for n = 0, 1, 2, 3 and up. Decimals are handled by the gamma function, a related but separate tool.
How many ways can you arrange 8 items?
8! = 40,320. Each additional item multiplies the previous count by one more than before, which is why the values climb so fast.
Is n factorial always bigger than 2 to the power n?
Not at first: 3! = 6 while 2^3 = 8. From n = 4 on, the factorial wins, because it keeps multiplying by ever larger factors while 2^n multiplies by 2 each time.
How does factorial relate to combinations?
Combinations divide the arrangements out: C(n, k) = n! / (k! x (n - k)!). For a 5 card hand from 52 cards that is 52! / (5! x 47!) = 2,598,960 hands.
What is a double factorial?
n!! multiplies every other integer down to 1 or 2: 9!! = 9 x 7 x 5 x 3 x 1 = 945, and 8!! = 8 x 6 x 4 x 2 = 384. It is written with two marks but is unrelated to (n!)!.
Spotted a wrong number or a broken result?
More Math tools
Fee schedules, rates and rules change without notice. Always confirm important figures with the official source before you rely on them.