Factorial Calculator

For n up to 170 the exact value is shown. Beyond 170 the result exceeds double precision, so a scientific approximation and digit count are reported instead.

n! (exact)120
Approximation1.2000e+2
Number of Digits3

The factorial of a non-negative integer n, written n!, is the product of every whole number from 1 up to n. It counts the number of ways to arrange n distinct items in order and underpins permutations, combinations, and probability. This calculator returns the exact value for n up to 170 and switches to a scientific approximation with an exact digit count for larger n.

Formula

n! = n × (n − 1) × (n − 2) × … × 2 × 1, with 0! = 1

n
A non-negative integer
n!
The factorial — the product of all integers from 1 to n

How it works

  1. Enter a non-negative integer n. The calculator multiplies 1 × 2 × 3 × … × n to build the factorial.
  2. For n up to 170 the exact product fits in double-precision arithmetic and is shown in full; for larger n the value overflows, so a mantissa-and-exponent approximation is given instead.
  3. It also reports the number of decimal digits in n! using the sum of base-10 logarithms, which stays accurate even when the full number is too large to display.

Worked example

Find 6! — the number of ways to order six different books on a shelf.

  1. Multiply 1 × 2 × 3 × 4 × 5 × 6.
  2. 1×2 = 2, ×3 = 6, ×4 = 24, ×5 = 120, ×6 = 720.

6! = 720, so there are 720 possible orderings.

Frequently asked questions

Why is 0! equal to 1?
There is exactly one way to arrange zero items — the empty arrangement — so 0! is defined as 1. This convention also keeps the formulas for permutations and combinations consistent.
Can I take the factorial of a negative or fractional number?
The ordinary factorial is only defined for non-negative integers, so this calculator rejects negatives and decimals. Extensions such as the gamma function generalize factorials to other numbers but are not computed here.
Why does the exact value stop at 170?
171! exceeds the largest finite value a JavaScript double can hold, so it would round to infinity. For n above 170 the calculator instead shows a scientific approximation and the exact number of digits.
How does factorial relate to permutations and combinations?
Permutations nPr equal n!/(n−r)! and combinations nCr equal n!/(r!(n−r)!). Both are built directly from factorials, which is why factorial growth makes counting problems explode so quickly.