ToolNestr

Factorial Calculator

Compute the factorial of any integer from 0 to 170 with a complete multiplication breakdown for smaller values.

Reviewed by the ToolNestr Editorial Team — July 2026

10! = 3,628,800
Cascading multiplication chain showing 5! = 120 as a step-by-step product Five numbers arranged in a cascading chain: 1 × 2 × 3 × 4 × 5 = 120, with arrows showing the sequential multiplication flowing from left to right. How 5! = 120 is built step by step 1 Start 2 1 × 2 = 2 3 2 × 3 = 6 4 6 × 4 = 24 5 24 × 5 = 120 5! = 120
Factorials build cumulatively: each step multiplies the previous result by the next integer.

How factorials work

The factorial of a non-negative integer n, denoted n!, is the product of all positive integers less than or equal to n. It is defined as n! = n × (n-1) × (n-2) × ... × 2 × 1, with the special case 0! = 1. Factorials represent the number of ways to arrange n distinct objects in a sequence — the number of permutations of n items.

Factorials grow at an astonishing rate. While 5! is only 120, 10! reaches 3.6 million, and 15! tops 1.3 trillion. This explosive growth is why factorials appear in probability and combinatorics — they count the astronomically large number of possibilities that arise when arranging even modest-sized sets of items.

The factorial function is defined recursively as n! = n × (n-1)!, with the base case 0! = 1. This recursive definition is both mathematically elegant and provides a natural way to compute factorials programmatically. The gamma function extends the concept to real and complex numbers, with Γ(n) = (n-1)! for positive integers.

The formula explained

Factorial definition

n! = n × (n-1) × ... × 2 × 1

For integer n ≥ 1, multiply all integers from 1 to n. By convention, 0! = 1.

Recursive form

n! = n × (n-1)!, 0! = 1

Each factorial builds on the previous one. 5! = 5 × 4! = 5 × 24 = 120.

Worked example: 7!

Step 1: 7! = 7 × 6 × 5 × 4 × 3 × 2 × 1

Step 2: 7 × 6 = 42

Step 3: 42 × 5 = 210

Step 4: 210 × 4 = 840

Step 5: 840 × 3 = 2,520

Step 6: 2,520 × 2 = 5,040

Step 7: 5,040 × 1 = 5,040

Therefore: 7! = 5,040

This means there are 5,040 ways to arrange 7 distinct items in a sequence.

🎲

Gamblers & Statisticians

Factorials are essential for calculating odds. The number of possible poker hands is 52!/(47! × 5!). Lottery odds, card game probabilities, and many gambling calculations rely on factorial-based combinations.

📐

Students & Teachers

Permutations (nPr = n!/(n-r)!) and combinations (nCr = n!/(r!(n-r)!)) are fundamental in probability and statistics courses. The binomial theorem uses factorials in its coefficients: (x + y)ⁿ = Σ(nCr) x^(n-r) y^r.

📈

Mathematicians

Factorials appear in Taylor series (eˣ = Σ xⁿ/n!), the gamma function, Stirling's approximation, and many number theory contexts. The number of trailing zeros in n! is determined by the number of factors of 5 in its prime factorization.

💻

Computer Scientists

Factorials appear in algorithm analysis (the traveling salesman problem has n! possible routes), combinatorial optimization, and the analysis of sorting networks. Stirling's approximation n! ≈ √(2πn)(n/e)ⁿ is used in complexity theory.

How to use the factorial calculator

1

Enter the number

Type any integer n from 0 to 170 in the input field. The calculator accepts only whole numbers in this range.

2

Watch the result

The factorial appears instantly. For n up to 20, a step-by-step multiplication breakdown is shown so you can follow the calculation.

3

Check the approximation

For larger values (n > 10), Stirling's approximation is shown alongside the exact result so you can see how well the approximation works.

Tips for working with factorials

Stirling's approximation

For large n, Stirling's approximation n! ≈ √(2πn)(n/e)ⁿ gives an excellent estimate. The relative error drops below 1% for n > 10 and continues to improve as n grows. This approximation is widely used in physics and computer science when exact values are impractical.

Cancellation in combinations

When computing nCr = n!/(r!(n-r)!), you can cancel factors rather than computing huge factorials. For example, 52!/(50! × 2!) simplifies to (52 × 51)/(2 × 1) = 1,326. This avoids arithmetic overflow and is much faster to compute.

Trailing zeros in n!

The number of trailing zeros at the end of n! is determined by the number of factors of 5 in the numbers from 1 to n (since factors of 2 are always more abundant). The count is floor(n/5) + floor(n/25) + floor(n/125) + ... For example, 25! has 6 trailing zeros.

Double factorials

A related concept is the double factorial n!! which is the product of every other integer. For even n: n!! = n × (n-2) × ... × 2. For odd n: n!! = n × (n-2) × ... × 1. For example, 7!! = 7 × 5 × 3 × 1 = 105. Double factorials appear in Wallis product and some integrals.

Related tools

Frequently asked questions

What is a factorial?

The factorial of n (written n!) is the product of all positive integers from 1 to n. For example, 5! = 5 × 4 × 3 × 2 × 1 = 120. By definition, 0! = 1.

What is 0! and why is it 1?

0! = 1 by convention. This definition makes combinatorial formulas work correctly — there is exactly one way to arrange zero items, and it ensures that n! = n × (n-1)! holds for n = 1.

How large can a factorial be?

Factorials grow extremely fast. 10! = 3,628,800, 20! ≈ 2.43 × 10¹⁸, and 170! is the largest factorial JavaScript can represent exactly (≈ 7.26 × 10³⁰⁶). Beyond that, values overflow to Infinity.

Where are factorials used?

Factorials appear in permutations and combinations (nPr, nCr), probability distributions (Poisson, binomial), Taylor series expansions, and the gamma function which extends factorials to real numbers.

What is the gamma function?

The gamma function Γ(n) extends the factorial to real and complex numbers. For positive integers, Γ(n) = (n-1)!. So Γ(6) = 5! = 120. It is defined by an integral: Γ(z) = ∫₀^∞ t^(z-1)e^(-t) dt.

All tool categories

Math (23 tools)
🌐 Networking & IP Tools (36 tools)
🧮 Everyday (26 tools)
💪 Health & Fitness (30 tools)
💰 Finance (34 tools)
📄 PDF Tools (10 tools)
🎨 Creators (12 tools)
💻 Developers (24 tools)
⚡ Engineering & Science (24 tools)
⚛️ Physics (48 tools)
🧪 Chemistry (50 tools)
🧬 Biology (50 tools)
🏠 Construction & Home Improvement (105 tools)
👗 Clothing & Garment Tools (68 tools)
🍳 Cooking & Baking (9 tools)
🚗 Automotive (26 tools)
🖼️ Image Tools (13 tools)
🔐 Security & Hash (15 tools)
📝 Text Tools (15 tools)
🔍 SEO Tools (11 tools)
🔄 Converters (69 tools)
🕐 Time & Date (15 tools)
📊 Chart Generators (11 tools)
🕌 Islamic Tools (16 tools)