Factorial Calculator

Calculate n! exactly, even for very large n - free, no signup.

Factorial calculator

What this tool does

Enter any whole number n (up to 5,000) and get n! calculated exactly - the full, precise digit sequence, not a rounded or truncated approximation, even when the result runs to hundreds or thousands of digits.

Calculates n factorial (n!) - the product of every whole number from 1 to n - using arbitrary-precision integer arithmetic.

Stays exact past 18! (where JavaScript's regular Number type starts losing precision) and past 170! (where regular floating-point math overflows to Infinity).

Correctly returns 1 for 0!, the standard mathematical convention, rather than treating it as an error or undefined case.

Shows the exact digit count of the result alongside the full number, so you can see at a glance how large n! has become.

How to use it

  1. Enter n.
  2. Read the exact factorial below.

Why use this calculator

Factorials grow so fast that normal calculators show approximations or overflow. Exact arithmetic gives every digit.

Why we built it

We built the factorial calculator on arbitrary-precision integers, so the result stays exact past 18!. Count arrangements with the permutations and combinations calculator and see powers with the exponent calculator.

Related tools worth a look: the LCM & GCD Calculator.

Who this tool is for

  • Students and teachers
  • Programmers testing big-number code
  • Probability and combinatorics learners

When to use it

  • Combinatorics and probability.
  • Checking large factorial values.
  • Learning growth rates.
  • Programming tests.

Where ordinary calculators break

Factorials outgrow standard number precision astonishingly fast.

18! is already larger than 2^53, the largest integer JavaScript's regular Number type can represent without rounding error - and by 171!, ordinary floating-point math overflows entirely, silently returning Infinity instead of a number. A factorial calculator built on regular numbers doesn't announce this happening; it just quietly starts giving a wrong (or infinite) answer. This tool uses arbitrary-precision integer arithmetic throughout, so the exact digit sequence is always correct, no matter how large n gets - up to a 5,000 cap, past which the result is already thousands of digits long.

Why 0! equals 1, not 0

Factorial is defined as an empty product for zero, and that convention isn't arbitrary - it keeps the rest of mathematics consistent.

n! is the product of every whole number from 1 to n, and n! is also defined by the recursive rule n! = n x (n-1)!. Working that rule backward from 1! = 1 forces 0! to equal 1: since 1! = 1 x 0!, and 1! is 1, 0! must be 1 too. It also matches the 'empty product' convention used throughout mathematics - a product with no terms to multiply is defined as 1, the same way a sum with no terms is defined as 0. This isn't just a special-cased rule in this tool: it's the standard mathematical definition, and it's what keeps formulas like combinations (nCr) correct when r equals 0 or n.

What you give it, and what you get back

Input and output of Factorial Calculator
ItemDetails
InputA whole number n from 0 to 5,000.
Outputn! exactly with the digit count.
Notes0! is 1.

Issues you may run into

Common problems with Factorial Calculator
What you seeWhy it happensWhat to do
Very long outputThe result has many digits.Use the digit count or copy the number.
n over 5,000 refusedIt is capped.Use logarithms for estimates.
Non-integer inputFactorials need whole numbers.Use the gamma function elsewhere.

Assumptions and limitations

Frequently asked questions

How do I calculate a factorial online for free?

Enter n and the exact result appears instantly, computed with arbitrary-precision integers.

Why does a regular calculator give a different, rounded answer for large factorials?

Most calculators use standard floating-point numbers, which lose precision past about 15-17 significant digits - a large factorial like 25! already exceeds that.

What is the largest factorial this can calculate?

n is capped at 5,000, well past the point where the result becomes an impractically long string of digits.

Is the result always exact?

Yes - it's computed with arbitrary-precision integers, which never round or lose precision no matter how large the number gets.

Is my data uploaded anywhere?

No. Calculation happens entirely in your browser - nothing is sent to a server.

Why does this calculator say 0! = 1?

That's the standard mathematical definition, not a special case - it follows from the recursive rule n! = n x (n-1)! and the 'empty product' convention (a product of zero terms equals 1), and it's what keeps other formulas like combinations correct at their edges.

What happens if I enter a negative number or a decimal?

Negative numbers aren't valid inputs, since factorial is only defined for non-negative integers here (this tool doesn't compute the Gamma function, the continuous extension to non-integers), and any decimal you enter is rounded down to the nearest whole number before calculating.