No Login Data Private Local Save

Factorial Calculator – n! for Integers & Large Numbers

5
0
0
0

Factorial Calculator

Calculate n! for non-negative integers — from small numbers to massive results with tens of thousands of digits. Fast, accurate, using arbitrary-precision arithmetic.

n!
(Double Factorial)
Supports 0 – 10,000 • Results up to ~35,660 digits
Quick picks:
n! =
Enter a number and click Calculate to see the result.
Total Digits
Trailing Zeros
Scientific Notation
Stirling Approx.

Frequently Asked Questions

A factorial, denoted by n!, is the product of all positive integers from 1 up to n. For example, 5! = 5 × 4 × 3 × 2 × 1 = 120. Factorials are fundamental in combinatorics, probability theory, and many areas of mathematics. They count the number of ways to arrange n distinct objects (permutations). By convention, 0! = 1 and 1! = 1.

The value 0! = 1 is a convention that makes many mathematical formulas work elegantly. One way to understand it: there is exactly one way to arrange zero objects — the empty arrangement. Also, it ensures the recurrence relation n! = n × (n−1)! holds for n = 1: 1! = 1 × 0! → 1 = 1 × 0! → 0! = 1. This convention is universally accepted in combinatorics and analysis.

This calculator supports n up to 10,000, producing results with up to 35,660 digits. It uses JavaScript's BigInt arbitrary-precision arithmetic, which can theoretically handle much larger values. The upper limit of 10,000 is set for practical performance reasons — calculating 10,000! takes about 1–3 seconds on modern devices. For comparison, 100! has 158 digits, 1,000! has 2,568 digits, and 52! (deck of cards permutations) has 68 digits.

The standard factorial function n! is defined only for non-negative integers (0, 1, 2, 3, ...). For negative integers, the factorial is undefined (it would involve division by zero in the recurrence relation). For non-integer values (decimals, fractions), mathematicians use the Gamma function Γ(z), which extends the factorial to complex numbers: Γ(n) = (n−1)! for positive integers. This calculator focuses exclusively on non-negative integer factorials and double factorials.

The double factorial, written n!!, is the product of every other integer from n down to 1 (or 2). For an odd n: n!! = n × (n−2) × (n−4) × ... × 3 × 1. For an even n: n!! = n × (n−2) × (n−4) × ... × 4 × 2. For example: 7!! = 7 × 5 × 3 × 1 = 105 and 8!! = 8 × 6 × 4 × 2 = 384. By convention, 0!! = 1 and 1!! = 1. Double factorials appear in formulas for integrals, Wallis product, and the volume of hyperspheres. Toggle the switch above to try it!

Factorials grow faster than exponential functions. This is called super-exponential growth. For perspective: 10! = 3,628,800 (~3.6 million), 20! ≈ 2.43 × 10¹⁸ (2.4 quintillion), 52! ≈ 8.07 × 10⁶⁷ (more than the estimated number of atoms in the observable universe), and 100! ≈ 9.33 × 10¹⁵⁷. Stirling's approximation provides a way to estimate large factorials: n! ≈ √(2πn) × (n/e)ⁿ. For n = 1,000, the result already has 2,568 digits — far beyond what standard 64-bit floating-point numbers can represent precisely.

Trailing zeros in n! come from factors of 10, which is 2 × 5. Since there are always more factors of 2 than 5, the number of trailing zeros equals the number of times 5 appears as a factor in the numbers 1 through n. This is calculated using Legendre's formula: Z(n) = ⌊n/5⌋ + ⌊n/25⌋ + ⌊n/125⌋ + ⌊n/625⌋ + ... For example, 100! has ⌊100/5⌋ + ⌊100/25⌋ + ⌊100/125⌋ = 20 + 4 + 0 = 24 trailing zeros. This calculator displays the trailing zeros count for every result — a fun mathematical insight!

Factorials appear throughout mathematics, science, and engineering:
  • Combinatorics: Counting permutations (n! ways to arrange n items) and combinations (nCr = n!/(r!(n−r)!)).
  • Probability: The Poisson distribution, binomial distribution, and many probability formulas use factorials.
  • Taylor Series: Expansions of eˣ, sin(x), cos(x), and other functions involve factorials in denominators.
  • Number Theory: Wilson's theorem states (p−1)! ≡ −1 (mod p) for prime p.
  • Computer Science: Analyzing algorithm complexity (e.g., O(n!) for brute-force traveling salesman).
  • Statistical Mechanics: Boltzmann's entropy formula involves factorials for counting microstates.

Stirling's approximation is a powerful formula for estimating large factorials without computing them fully: n! ≈ √(2πn) × (n/e)ⁿ. The approximation becomes more accurate as n increases. For n = 10, it's about 0.8% off; for n = 100, it's about 0.08% off. In logarithmic form: ln(n!) ≈ n·ln(n) − n + ½ln(2πn). This calculator shows the Stirling approximation for each result in the statistics panel, expressed in scientific notation so you can compare it with the exact value.

Yes, absolutely. This calculator uses JavaScript's BigInt data type, which performs exact integer arithmetic without any rounding or floating-point approximation. Every digit displayed in the result is mathematically precise. Unlike calculators that use floating-point numbers (which have ~15-17 significant digits of precision), BigInt can represent integers of arbitrary size with perfect accuracy. The only limitation is computational time and memory — which is why we cap input at 10,000 to ensure a responsive experience.