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!.

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!.

Why Use This Factorial Calculator?

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 This Calculator

  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. Review the output cards and verify both the primary answer and supporting values.
  4. Use the visual section to compare magnitude, direction, or distribution at a glance.
  5. Check the table for step-by-step details, intermediate values, or scenario comparisons.
  6. Adjust one input at a time to see how each parameter changes the final result.

Formula

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

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.

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

What is factorial used for?

Factorials appear in permutations (n!), combinations (n! / (k!(n−k)!)), probability, Taylor series, and counting problems in combinatorics.

How fast does factorial grow?

Factorial grows faster than exponential: 10! = 3,628,800; 20! ≈ 2.43 × 10^18; 100! has 158 digits. This rapid growth is called super-exponential.

Why is 0! equal to 1?

By convention, 0! = 1 because there is exactly one way to arrange zero objects. This base case also ensures that combinatorial formulas like n!/(n−r)! stay consistent when r = n.

How quickly do factorials grow?

Factorials grow extremely fast: 10! = 3,628,800 and 20! ≈ 2.4 × 10^18. Stirling's approximation ln(n!) ≈ n·ln(n) − n is often used for large values of n.

Where are factorials used outside of combinatorics?

Factorials appear in Taylor series expansions, probability distributions such as the Poisson distribution, and the Gamma function. They are also central to counting permutations and combinations.

Related Pages