Factorial Calculator

Compute n! with step-by-step multiplication, permutations, combinations, double factorial, Stirling approximation, trailing zeros, digit count, growth visualization, and a reference table up to 25!.

Non-negative integer, max 170
Choose r items from n
10!
3,628,800
10 factorial
P(10, 3)
720
Permutations: 10! / (10−3)!
C(10, 3)
120
Combinations: 10! / (3!(10−3)!)
Double Factorial
3,840
10!! = product of every other integer down to 1 or 2
Stirling Approx.
3,598,696
√(2πn)(n/e)ⁿ — error: 0.8296%
Number of Digits
7
log₁₀(10!) ≈ 6.56
Trailing Zeros
2
Factors of 5 in 10!
Γ(n+1) = n!
3,628,800
Gamma function extends factorial to real/complex numbers
Factorial Growth (first 10 steps)
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

Step-by-Step Computation

StepOperationRunning Product
1× 11
2× 22
3× 36
4× 424
5× 5120
6× 6720
7× 75,040
8× 840,320
9× 9362,880
10× 103,628,800
Factorial Reference Table

Key Factorial Identities

IdentityFormulaNote
Definitionn! = n × (n−1) × … × 2 × 1Product of 1 to n
0! = 1By convention (empty product)Required for combinatorics to work
Recursiven! = n × (n−1)!Base case: 0! = 1
PermutationsP(n,r) = n! / (n−r)!Ordered selections
CombinationsC(n,r) = n! / (r!(n−r)!)Unordered selections
Stirlingn! ≈ √(2πn)(n/e)ⁿApproximation for large n
Gamma FunctionΓ(n+1) = n! for n ∈ ℕExtends factorial to reals/complex
Double Factorialn!! = n(n−2)(n−4)…Product of every other integer
Trailing ZerosΣ ⌊n/5ᵏ⌋Count factors of 5 in n!
Planning notes, formulas, and examples

About the Factorial Calculator

The **Factorial Calculator** computes n! (n factorial) — the product of all positive integers from 1 to n — and extends that into permutations, combinations, double factorials, Stirling's approximation, and more. It handles any non-negative integer up to 170 (beyond which JavaScript numbers overflow to infinity) and provides a step-by-step computation, growth visualization, and a full reference table.

The factorial function is one of the most important in discrete mathematics. It counts the number of ways to arrange n distinct objects: 10 books can be shelved in 10! = 3,628,800 different orders. Factorials appear in permutations (P(n,r) = n!/(n−r)!), combinations (C(n,r) = n!/(r!(n−r)!)), probability theory, Taylor series, and throughout physics and engineering.

Because factorials grow astronomically fast — 20! already exceeds 2 quintillion — the calculator also shows the number of digits and Stirling's approximation (√(2πn)(n/e)ⁿ), which becomes remarkably accurate for large n. The trailing zeros output counts how many zeros appear at the end of n!, determined by the number of times 5 divides into the factorial.

Enter n and an optional r for permutations and combinations. Eight output cards display n!, P(n,r), C(n,r), double factorial (n!!), Stirling's approximation with its relative error, digit count, trailing zeros, and the gamma function connection. The bar chart shows how explosively factorial grows, and the reference table lets you look up any value from 0! to 25!.

When This Page Helps

Factorials show up in far more places than simple multiplication drills. If you are counting arrangements, computing combinations, estimating probabilities, or checking a Taylor-series formula, you usually need more than just the value of n!. This calculator places the core count together with permutations, combinations, double factorial, digit count, and trailing zeros so you can answer the surrounding problem without switching tools.

It is also useful because factorial values become enormous almost immediately. The step table helps verify small cases, while Stirling's approximation and the growth bars give you a realistic sense of scale for larger inputs. That makes the tool practical for both classroom work and algorithm design, where understanding how quickly n! grows is often just as important as the exact number itself.

How to Use the Inputs

  1. Enter values in n (factorial input), r (for permutations/combinations).
  2. Use a preset such as "5!" or "7!" to load a quick example.
  3. Compare n!, permutations, combinations, digit count, and trailing zeros in the output cards.
  4. Compare the result with the formula and worked example so you can catch input, rounding, or setup mistakes.
Formula used
n! = 1 × 2 × 3 × … × n. P(n,r) = n!/(n−r)!. C(n,r) = n!/(r!(n−r)!). Stirling: n! ≈ √(2πn)(n/e)ⁿ. Trailing zeros = Σ ⌊n/5ᵏ⌋.

Example Calculation

Result: For these inputs, the calculator returns the factorial result plus supporting breakdown values shown in the output cards.

This example reflects the built-in factorial workflow: enter values, apply options, and read both the main answer and supporting metrics.

Tips & Best Practices

  • Check that all inputs use the same scale and assumptions before trusting the result.
  • Compare the answer with the worked example or a rough estimate to catch entry mistakes.

Why Factorials Grow So Fast

Factorial growth is super-exponential compared with familiar arithmetic sequences. Each step multiplies by a larger integer than the last one, so values jump from manageable to enormous very quickly: 5! is 120, 10! is 3,628,800, and 20! is already over 2 quintillion. The growth chart in this calculator makes that jump visible instead of leaving it as an abstract statement.

Connecting n! To Counting Problems

In combinatorics, n! counts how many ways you can arrange n distinct objects in order. From there, permutations and combinations are just structured variations on the same idea: P(n,r) counts ordered selections, while C(n,r) counts unordered selections. That is why this calculator includes both formulas next to the main factorial value. In real problems, you often need all three together.

Trailing Zeros, Double Factorials, And Approximations

The extra outputs cover the parts students and developers usually look up separately. Trailing zeros come from counting factors of 5 in n!, double factorials appear in series expansions and combinatorics, and Stirling's approximation gives a fast estimate when exact values become unwieldy. Seeing those side by side helps you understand factorial as a broader family of tools rather than a single definition.

Sources & Methodology

Last updated:

Frequently Asked Questions

  • 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 convention, 0! = 1.