← Home

🔢 Factorial Calculator

Compute the factorial of any non-negative integer instantly.

What is this tool?

The Factorial Calculator is a free online tool that computes the factorial of any non-negative integer. Factorials are a fundamental concept in combinatorics, probability, and many areas of mathematics and computer science. This calculator handles large inputs with full precision using arbitrary-precision arithmetic. The factorial of a non-negative integer n, written as 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. Factorials grow extremely fast: 10! is already 3,628,800, 20! is about 2.4 × 10¹⁸, and 100! has 158 digits. This rapid growth makes factorials essential for counting permutations and combinations. Factorials appear everywhere in mathematics. They are used to calculate the number of ways to arrange objects (permutations), the number of ways to choose items from a set (combinations), the coefficients in the binomial theorem, Taylor series expansions in calculus, and probability distributions like the Poisson distribution. This calculator uses BigInt arithmetic to handle arbitrarily large factorials without loss of precision.

How it works

The calculator computes factorials using BigInt, JavaScript's built-in arbitrary-precision integer type. Regular JavaScript numbers lose precision for integers above 2⁵³ (about 9 × 10¹⁵), which means 20! and above would be inaccurate with normal numbers. BigInt avoids this limitation entirely, so the calculator can compute 1000! or even larger factorials with exact precision. The algorithm is a simple iterative multiplication: start with 1, then multiply by each integer from 2 up to n. For efficiency with very large numbers, the implementation uses a divide-and-conquer approach for multiplication of large BigInt values, which is faster than naive sequential multiplication for big inputs. The calculator also provides the number of digits in the result, which is useful for understanding the magnitude of large factorials. It uses the Stirling approximation formula to estimate the digit count for verification: log₁₀(n!) ≈ n × log₁₀(n) - n × log₁₀(e) + 0.5 × log₁₀(2πn).
Ad

How to use

  1. Enter a non-negative integer (0 to 10000).
  2. Click Calculate to compute the factorial.
  3. View the exact result with digit count.
  4. Copy the full result to your clipboard.
  5. Try different values to explore factorial growth.

Frequently Asked Questions

Frequently Asked Questions

How fast do factorials grow?
Factorials grow faster than exponential functions. 5! = 120, 10! = 3,628,800, 20! ≈ 2.4 × 10¹⁸. By 70!, the result exceeds the number of atoms in the observable universe.

Why is 0! equal to 1?
By definition, 0! = 1. This makes mathematical formulas consistent. For example, the number of ways to arrange 0 objects is 1 (the empty arrangement), and combinations formula C(n,0) = 1 requires 0! = 1.

What is the largest factorial I can compute?
This calculator handles factorials up to about 10000! using BigInt arithmetic. Beyond that, the computation may take too long or the result may be too large to display efficiently.

How are factorials used in real life?
Factorials count permutations: 5 books can be arranged on a shelf in 5! = 120 ways. They are used in probability (Poisson distribution), statistics (binomial coefficients), physics (quantum mechanics), and computer science (algorithm analysis).

Tips & Advice

Factorials are the cornerstone of combinatorics. The number of ways to arrange n distinct objects is n!. The number of ways to choose k objects from n is n! / (k! × (n-k)!). When working with large factorials, Stirling's approximation gives a quick estimate: n! ≈ √(2πn) × (n/e)ⁿ. Remember that factorials grow faster than exponential functions, which is why algorithms with factorial time complexity (like brute-force permutations) become impractical for n > 12 or so. For probability calculations involving factorials, often you can cancel terms before multiplying to avoid dealing with huge intermediate numbers.

Related Tools

Ad