Factorial Calculator

Factorial Calculator

Compute n!, the product of all positive integers up to n. Essential for permutations, combinations, and probability.

Last updated: May 2026 | By Patchworkr Team

Result will appear here...

Factorial Reference

nn!
01
11
22
36
424
5120
103,628,800

What is a Factorial?

The factorial of a non-negative integer $n$, written $n!$, is defined as the product of all positive integers from 1 up to $n$. This simple multiplicative definition hides a powerful combinatorial meaning: $n!$ counts the number of distinct orderings (permutations) of $n$ labeled items. Factorials grow extremely rapidly—doubling the input roughly multiplies the output by a factorial-scale factor—so even modest values of $n$ lead to very large numbers. For practical calculator use, we compute factorials using straightforward iterative multiplication for small-to-moderate inputs and display both exact and scientific notation when the result becomes large. The implementation guards against JavaScript floating-point overflow by limiting exact computation to values where native numbers remain finite (commonly up to about 170!).

Beyond counting arrangements, factorials connect to many areas of mathematics and applied science: they appear in series expansions (Taylor series), in analytic continuations through the Gamma function for non-integer arguments, and in probability when computing permutations and combinations. Approximation formulas such as Stirling's approximation provide accurate estimates for very large $n$ when exact values are impractical. In algorithms and software, factorials often signal combinatorial complexity—if a problem requires evaluating $n!$ possibilities, it may be computationally infeasible to brute force for large $n$. This calculator is designed to be an approachable, auditable tool: it presents exact results when possible, scientific formatting for readability, and clear error messages for inputs outside safe bounds.

How to Use This Calculator

  1. Enter a non-negative integer `n` in the input field (allowed range: 0–170).
  2. The calculator computes `n!` by iterative multiplication and displays the result immediately.
  3. If the value is large, a scientific notation summary is shown and the exact value is truncated for readability.
  4. Use the result to compute permutations, combinations, or to check combinatorial formulas; copy the exact or scientific output as needed.
  5. For values outside the safe range, the tool returns a clear error and suggests using arbitrary-precision libraries or Stirling's approximation for estimates.

The Formula

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

Special Case: 0! is defined as 1.

Example Calculation

Calculate 4!:

1. Start with n = 4

2. Multiply: 4 × 3 × 2 × 1

3. 4 × 3 = 12

4. 12 × 2 = 24

5. 24 × 1 = 24

Final Answer: 24

Frequently Asked Questions

Why is 0! equal to 1?

It is defined this way to make many formulas consistent and represents the one arrangement of zero objects.

How fast do factorials grow?

Very rapidly — values explode combinatorially; 10! is over 3 million.

Can you calculate factorials for non-integers?

Yes, via the Gamma Function Γ(n), which generalizes factorials.

What is Stirling's Approximation?

An estimate for large n: n! ≈ √(2πn) (n/e)^n, useful when exact values are impractical.

What is 0! used for?

It ensures combinatorial formulas (like permutations) remain consistent (0! = 1).

Are factorials used outside math contests?

Yes — in statistics, physics, probability, and algorithm analysis.

Why limit input to 170?

Beyond ~170, JS numbers overflow to Infinity; the tool guards against that.

How to compute very large factorials?

Use arbitrary-precision libraries or approximations like Stirling's formula.

Related Tools