Free to Use

🔍 Factorial Calculator

Calculate the factorial of any non-negative integer n (n!) with a detailed step-by-step breakdown showing each multiplication step. Perfect for combinatorics, permutations, and math studies.

n must be between 0 and 170 (inclusive). Factorials grow extremely fast — 170! has 309 digits.

Factorial Examples in Action

🎯 Simple Factorial: 5!

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

This is one of the most common introductory factorial examples. Start with 5, multiply by each integer down to 1.

🔢 The Special Case: 0!

By definition, 0! = 1

The factorial of zero is defined as 1. This might seem counterintuitive, but it's essential for formulas in combinatorics (like choosing 0 items from a set) and makes many mathematical formulas work correctly.

📊 Arranging Books on a Shelf

You have 7 different books to arrange on a shelf. How many possible arrangements are there?

Solution: 7! = 7 × 6 × 5 × 4 × 3 × 2 × 1 = 5,040

There are 5,040 different ways to arrange 7 books on a shelf. This is a classic permutations problem.

🧑‍🤝‍🧑 Forming a Committee

From a group of 10 people, how many ways can you choose a committee of 3?

Solution: This uses the combination formula: C(10,3) = 10! / (3! × 7!)

10! = 3,628,800, 3! = 6, 7! = 5,040 → C(10,3) = 3,628,800 / (6 × 5,040) = 120

There are 120 possible committees of 3 people from a group of 10.

Understanding Factorials

The factorial of a non-negative integer n, denoted as n!, is the product of all positive integers less than or equal to n. Factorials are defined mathematically as:

n! = n × (n-1) × (n-2) × ... × 2 × 1
For n ≥ 1, and by definition 0! = 1

How Factorials Work

1
Start with the number n and multiply it by (n-1)
2
Continue multiplying by each decreasing integer: n × (n-1) × (n-2) × ...
3
Stop when you multiply by 1 — the result is n!
4
Special case: 0! = 1 by definition, which makes formulas in combinatorics work consistently

Recursive Definition

Factorials can also be defined recursively, which is helpful in computer programming:

0! = 1
n! = n × (n-1)! for n ≥ 1
Each factorial builds on the previous one

Growth of Factorials

Factorials grow extremely quickly. Even relatively small inputs produce enormous results. For example, 10! = 3,628,800, but 20! = 2,432,902,008,176,640,000 (about 2.4 quintillion). The maximum n our calculator handles is 170, which produces a 309-digit number. This limit is due to JavaScript's BigInt precision constraints on very large numbers.

🔢
Simple Input
Enter any non-negative integer from 0 to 170 and instantly get the factorial result with full precision.
📝
Step-by-Step Breakdown
See every multiplication step clearly laid out — perfect for learning how factorials are computed.
📊
Digit Count
Know exactly how many digits are in the result — useful for understanding factorial growth rates.
🎓
Educational Tool
Ideal for students learning combinatorics, permutations, or anyone exploring the fascinating world of factorials.

What is a Factorial?

A factorial is a mathematical operation that multiplies a given non-negative integer n by every positive integer less than it, down to 1. Denoted by an exclamation mark (n!), it's one of the most fundamental concepts in combinatorics, probability theory, and many areas of higher mathematics.

The factorial function grows at an astonishing rate — much faster than exponential functions. While 10! is already 3,628,800 (3.6 million), 20! is over 2.4 quintillion, and 170! produces a number with 309 digits. This rapid growth makes factorials essential in fields like statistics, physics, and computer science where large combinatorial calculations are common.

The factorial operation is deeply connected to the Gamma function, which extends the factorial concept to real and complex numbers. For positive integers, Γ(n+1) = n!, making the Gamma function the continuous analogue of the discrete factorial.

Why is 0! = 1?

The definition of 0! = 1 might seem arbitrary at first, but it's necessary for consistency. Consider that n! = n × (n-1)!. If we set n = 1, we get 1! = 1 × 0!, so 0! must equal 1 for the formula to work. Additionally, in combinatorics, the number of ways to choose all n items from a set of n items — or to choose nothing (0 items) — is exactly 1, making 0! = 1 the natural definition.

Where Factorials Are Used

Factorials appear throughout mathematics and its applications. Understanding them is essential for many areas of study and practical problem-solving.

🔄 Permutations

The number of ways to arrange n distinct items in a sequence is n!. For example, 5 books can be arranged in 5! = 120 different orders on a shelf.

🔀 Combinations

The number of ways to choose k items from a set of n items is C(n,k) = n! / (k! × (n-k)!). This formula is the foundation of the binomial theorem and probability calculations.

📈 Probability & Statistics

Factorials appear in probability distributions like the Poisson distribution, in calculating expected values, and in the fundamental counting principle.

🧮 Calculus & Series

Factorials appear in Taylor series expansions, where functions like e^x are expressed as infinite sums involving factorials in the denominators.

Frequently Asked Questions

What is the factorial of a negative number?
Factorials are defined only for non-negative integers (0, 1, 2, 3, ...). The factorial of a negative number is not defined in standard mathematics. The Gamma function extends the concept to negative non-integer values, but it has poles (infinite values) at negative integers.
How fast do factorials grow?
Factorials grow extremely fast. Here's a quick reference: 5! = 120, 10! = 3,628,800, 15! ≈ 1.3 trillion, 20! ≈ 2.4 quintillion, 50! has about 65 digits, and 170! has 309 digits — the largest our calculator handles. The growth rate is approximately n! ~ √(2πn)(n/e)^n according to Stirling's approximation.
Why can't I calculate factorials larger than 170?
The limit of 170 is due to computational precision. While JavaScript's BigInt can handle arbitrarily large integers, factorial results beyond 170! would have thousands of digits and would be impractical for the step-by-step display. For truly massive factorials, specialized mathematical software like Wolfram Alpha or dedicated number theory libraries are recommended.
What is the relationship between factorials and the Gamma function?
The Gamma function Γ(z) extends the factorial concept to complex numbers. For positive integers n, Γ(n+1) = n!. The Gamma function is defined for all complex numbers except negative integers, making it one of the most important special functions in mathematics with applications in physics, engineering, and statistics.
How do I calculate factorials in programming?
Factorials can be calculated using loops or recursion. In JavaScript: function factorial(n) { let result = 1n; for (let i = 2n; i <= n; i++) result *= i; return result; } using BigInt for large numbers. Other languages have similar approaches, and many provide built-in factorial functions in their standard math libraries.
What are double factorials?
A double factorial n!! is the product of integers with the same parity as n, down to 1 (or 2). For odd n: n!! = n × (n-2) × (n-4) × ... × 1. For even n: n!! = n × (n-2) × (n-4) × ... × 2. For example, 7!! = 7 × 5 × 3 × 1 = 105, and 8!! = 8 × 6 × 4 × 2 = 384. Double factorials appear in trigonometric integrals and the Wallis product formula for π.

⚠️ Educational Use Notice: This Factorial Calculator is designed for educational and reference purposes. Results are accurate for the supported range (0-170). For extremely large factorials beyond 170!, specialized mathematical software is recommended. Always verify critical calculations independently.