Factorial Calculator

Enter a non-negative integer n to compute n! exactly, with full step-by-step expansion.

n! = ?
Enter a non-negative integer above to compute its factorial.

What is a factorial?

The factorial of a non-negative integer n, written as n! (read "n factorial"), is the product of all positive integers from 1 up to n. It tells you the number of ways to arrange n distinct objects in order, which is why factorials are central to permutations, combinations, and probability.

n! = n × (n−1) × (n−2) × … × 2 × 1

By definition, 0! = 1. This may look surprising, but it keeps formulas like the combinations formula nCr = n! / (r!(n−r)!) consistent — there is exactly one way to arrange zero objects (the empty arrangement). Factorial is only defined for non-negative integers; negative numbers and fractions do not have a standard factorial (those use the Gamma function instead).

Worked example: 5!

5! = 5 × 4 × 3 × 2 × 1 = 120. There are 120 distinct ways to order 5 different books on a shelf.

Recursive rule

n! = n × (n−1)!. For instance 6! = 6 × 5! = 6 × 120 = 720. This is how factorials are often computed in code.

Grows fast

Factorials grow extremely quickly: 10! = 3,628,800 and 20! is over 2 quintillion. This calculator uses exact arithmetic so big results stay precise.

Frequently asked questions

Why is 0! equal to 1?

By convention 0! = 1. There is exactly one way to arrange an empty set of objects — do nothing — so the count of arrangements is 1. This definition also keeps key formulas consistent, such as the combinations formula nCr = n! / (r!(n−r)!), which requires 0! = 1 when r = 0 or r = n.

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

Not with the ordinary definition. The standard factorial is only defined for non-negative integers (0, 1, 2, 3, …). Negative numbers and fractions do not have an elementary factorial. Mathematicians extend the idea to other numbers using the Gamma function, where n! = Γ(n+1), but that is beyond a basic factorial calculator.

How big can n be in this calculator?

This tool computes the exact value of n! for n up to 1000 using BigInt arithmetic, so even very large results are precise with no rounding. We cap the input at 1000 because larger factorials produce numbers with thousands of digits that are impractical to display. The step-by-step expansion is shown only for small n to keep it readable.

What are factorials used for?

Factorials count arrangements and selections. They appear in permutations (nPr = n! / (n−r)!), combinations (nCr = n! / (r!(n−r)!)), probability, the binomial theorem, Taylor series in calculus, and many counting problems in statistics and computer science.

How is a factorial calculated step by step?

Start at n and multiply by every whole number below it down to 1. For example, 4! = 4 × 3 × 2 × 1: first 4 × 3 = 12, then 12 × 2 = 24, then 24 × 1 = 24. So 4! = 24. You can also use the recursive rule n! = n × (n−1)!.