Home › Calculators › Factorial Calculator

Factorial Calculator

Calculate n! exactly for any whole number from 0 to 5,000, with every digit. You also get the digit count, trailing zeros, the double factorial n!! and a nearby-factorials table.

Last updated:

Whole number from 0 to 5,000

Enter your values to see the result.
Advertisement
Advertisement

How to use the Factorial Calculator

  1. Enter a whole number n from 0 to 5,000, or tap an example.
  2. Press Calculate factorial (results also update as you type).
  3. Read n!, its digit count, trailing zeros and n!!.
  4. Scroll the exact value box for every digit, or press Copy results to copy them all.

Factorial formulas

  • Factorial: n! = n × (n − 1) × (n − 2) × … × 2 × 1, with 0! = 1
  • Recursive rule: n! = n × (n − 1)!
  • Double factorial: n!! = n × (n − 2) × (n − 4) × … ending at 1 (odd n) or 2 (even n)
  • Trailing zeros (Legendre): Z(n) = ⌊n/5⌋ + ⌊n/25⌋ + ⌊n/125⌋ + …
  • Number of digits: ⌊log₁₀ 1 + log₁₀ 2 + … + log₁₀ n⌋ + 1
  • Stirling's approximation: n! ≈ √(2πn) · (n / e)n

Factorial table 0! to 20!

nn!nn!
011139,916,800
1112479,001,600
22136,227,020,800
361487,178,291,200
424151,307,674,368,000
51201620,922,789,888,000
672017355,687,428,096,000
75,040186,402,373,705,728,000
840,32019121,645,100,408,832,000
9362,880202,432,902,008,176,640,000
103,628,8002151,090,942,171,709,440,000

21! is the first factorial that no longer fits in a 64-bit integer, and 171! overflows ordinary double-precision floating point. That is why this calculator uses exact big-integer arithmetic.

Frequently asked questions

What is a factorial?

n! (n factorial) is the product of all whole numbers from 1 to n. For example 5! = 5 × 4 × 3 × 2 × 1 = 120. It counts the number of ways to arrange n different items in a row.

Why is 0! equal to 1?

There is exactly one way to arrange zero items (do nothing), and the rule n! = n × (n − 1)! only works for n = 1 if 0! = 1. It also keeps formulas such as nCr = n! ÷ (r!(n − r)!) correct.

How many trailing zeros does 100! have?

24. Each trailing zero comes from a factor 10 = 2 × 5, and there are fewer 5s than 2s, so count the 5s: ⌊100/5⌋ + ⌊100/25⌋ = 20 + 4 = 24 (Legendre's formula).

How many digits does 100! have?

100! has 158 digits. In general the digit count is ⌊log₁₀(n!)⌋ + 1, which you can find by adding log₁₀ of every number from 1 to n.

What is a double factorial?

n!! multiplies every second number down from n: 7!! = 7 × 5 × 3 × 1 = 105 and 8!! = 8 × 6 × 4 × 2 = 384. It is not the same as (n!)!.

Can you take the factorial of a negative number or a decimal?

Not with the ordinary definition, which only covers whole numbers 0, 1, 2 and so on. The gamma function extends it to decimals (Γ(n + 1) = n!), but it is undefined at negative integers.

What is 52 factorial?

52! ≈ 8.0658 × 10^67, a 68-digit number. It is the number of ways to shuffle a standard deck of 52 cards, so a well-shuffled deck is almost certainly in an order that has never existed before.

Are all the tools on FreeToolCabin tested for quality and accuracy?

Yes! Every tool on our site undergoes automated Q/A testing in real browser environments to ensure high precision, correct output, and zero errors. If you happen to spot a bug or have a suggestion, please contact us at [email protected] and our team will review it right away.

Related tools

Permutation and Combination CalculatorCalculate nPr and nCr, with or without repetition, as exact big numbers.Probability CalculatorFind and, or, not, conditional and at-least-once probabilities from P(A) and P(B).Scientific CalculatorTrig, logs, powers and more in your browser.Exponent CalculatorRaise any number to a power, including negative and fractional exponents.Birthday Paradox CalculatorChance that two people in a group share a birthday, with a chart from 1 to 100 people.Collatz Conjecture CalculatorSee the full 3n + 1 sequence for any number: steps, peak value and a hailstone chart.Fibonacci CalculatorExact n-th Fibonacci number (BigInt), sequence lists, Fibonacci check and golden ratio.Graphing CalculatorPlot multiple functions with zoom, pan, intersections and a value table.Logarithm CalculatorCalculate log in any base, ln, log10, log2 and antilog with change-of-base steps.Quadratic Equation SolverSolve ax² + bx + c = 0 with exact roots, steps, vertex and a parabola graph.Matrix CalculatorAdd, multiply, invert and row-reduce matrices up to 5×5 with exact fractions and steps.Prime Number CheckerCheck if a number is prime, factor it with a factor tree and list primes in a range.GCF and LCM CalculatorFind the GCF and LCM of two or more numbers with Euclid steps and prime factorization.Cubic Yard CalculatorConvert length, width and depth in any unit to cubic yards, cubic feet, m³ and material weight.Prime Factorization CalculatorFind prime factors in exponent form with a factor tree, divisor count and divisors list.Modulo CalculatorCalculate a mod n and the quotient, with floored, truncated and Euclidean rules.Exponential Growth CalculatorExponential growth and decay: final amount, rate or time, discrete or continuous.Linear Regression CalculatorLeast-squares line of best fit: slope, intercept, r, r², predictions and a scatter plot.System of Equations SolverSolve 2×2, 3×3 and 4×4 linear systems with exact fractions and step-by-step working.Cubic Equation SolverSolve ax³ + bx² + cx + d = 0 for real and complex roots with steps and a graph.Summation CalculatorEvaluate sigma notation: sum any expression in n from a to b with partial sums and a chart.Arithmetic Sequence CalculatorFind the n-th term, sum and full list of an arithmetic sequence, or d from two terms.Geometric Sequence CalculatorFind the n-th term, sum and infinite sum of a geometric sequence, or r from two terms.Factors CalculatorAll factors and factor pairs of a number, prime factors, divisor count and perfect check.Depth of Field CalculatorNear and far focus limits, depth of field and hyperfocal distance for any camera or lens.Crop Factor CalculatorCrop factor, full-frame equivalent focal length and aperture, and field of view for any sensor.Completing the Square CalculatorRewrite ax² + bx + c in vertex form a(x − h)² + k step by step and solve it.Derivative CalculatorSymbolic derivative of any f(x) up to 5th order, with steps, slope at a point and a graph.Exposure Value CalculatorEV from aperture, shutter and ISO, or solve any missing setting with sunny 16 presets.Factoring Trinomials CalculatorFactor trinomials and polynomials: GCF, ac method, difference of squares, cubes, with steps.Integral CalculatorDefinite integral of f(x) from a to b with adaptive Simpson, area graph and antiderivative.Least Common Denominator CalculatorFind the LCD of two or more fractions and rewrite them as equivalent fractions, with steps.Limiting Reactant CalculatorFind the limiting reactant, theoretical yield and leftover excess from an equation.Parabola CalculatorVertex, focus, directrix, axis, intercepts and graph of a parabola from its equation.Polynomial Root FinderFind all real and complex roots of a polynomial up to degree 10, with the factored form.Prime Number List GeneratorList all primes in a range or the first N primes with a fast sieve; copy or download the list.Quadratic Regression CalculatorFit y = ax² + bx + c (or up to degree 6) to x, y data with R², predictions and a graph.Scatter Plot MakerPaste X,Y pairs for a scatter plot with trendline, equation, r and R². Download PNG.Factor Tree GeneratorDraw the prime factor tree of any number as a printable diagram, with exponent form and steps.Function Composition CalculatorFind f(g(x)), g(f(x)), f + g, f · g and f / g with values at a point and domains.X and Y Intercept CalculatorFind the x- and y-intercepts of lines, curves and functions with steps and a graph.Line Intersection CalculatorFind where two lines cross from equations, points or slopes, with parallel checks and a graph.Linear Programming SolverSolve max/min linear programs with the simplex method: tableau steps and a 2-variable graph.Modular Exponentiation CalculatorCompute a^b mod m for huge numbers with square-and-multiply steps (BigInt).Modular Inverse CalculatorFind a⁻¹ mod m with the extended Euclidean algorithm, step by step, for huge numbers too.Nth Term CalculatorFind the nth term formula of a sequence: arithmetic, geometric, quadratic or cubic.Partial Fraction Decomposition CalculatorSplit a rational function into partial fractions with the setup, equations and solution.Perpendicular Line CalculatorEquation of the perpendicular and parallel line through a point, with distance and a graph.Polar Graphing CalculatorGraph polar equations r = f(θ): roses, cardioids, spirals, with a θ range slider and PNG export.Polynomial CalculatorAdd, subtract, multiply, divide and evaluate polynomials; see roots, degree and a graph.Polynomial Long Division CalculatorDivide polynomials with the full long division layout, quotient, remainder and steps.Scale Factor CalculatorScale factor between similar figures, plus scaled lengths, areas (k²) and volumes (k³).Set CalculatorUnion, intersection, difference and complement of up to 4 sets, with a Venn diagram and counts.Table of Values CalculatorMake an x/y table for any function with a start, end and step, then plot it or copy CSV.Synthetic Division CalculatorDivide polynomials by x − c (synthetic table) or any polynomial (long division) with steps.3D Graphing CalculatorPlot z = f(x, y) surfaces and 3D parametric curves; rotate, zoom, add contours, save PNG.Algebra CalculatorSimplify, expand and factor algebraic expressions with exact answers and step-by-step working.Determinant CalculatorDeterminant of a 2×2 to 8×8 matrix with exact fractions and cofactor or row-reduction steps.Differential Equation SolverSolve first- and second-order ODEs step by step, with initial conditions, an RK4 check and a graph.Domain and Range CalculatorFind the domain and range of a function in interval notation, with steps and a graph.Eigenvalue and Eigenvector CalculatorEigenvalues (real or complex), eigenvectors and the characteristic polynomial of a square matrix.Equation SolverSolve any equation for x: exact roots, complex roots, numeric answers, steps and a graph.Inequality CalculatorSolve linear, quadratic, rational and absolute value inequalities with steps and a number line.Inverse Function CalculatorFind the inverse f⁻¹(x) of a function with steps, domain restrictions and a graph.Laplace Transform CalculatorLaplace transform of f(t) with the table rule used for each term and the region of convergence.Limit CalculatorEvaluate limits at a point or at infinity, one-sided or two-sided, with steps, table and graph.Linear Interpolation CalculatorInterpolate or extrapolate y for any x from two points or a data table, with steps and a plot.Matrix Inverse CalculatorFind the inverse of a 2×2 to 8×8 matrix in exact fractions with Gauss–Jordan or adjugate steps.
See all 74 Algebra & Calculus Calculators →