Factorial Calculator (n!)
Compute the factorial of a non-negative integer n, written n!, which is the product of all positive integers from 1 up to n. By definition 0! = 1.
Factorial grows extremely fast. For very large n the result may exceed normal numeric precision; values up to about n = 170 stay within standard double-precision range.
What the Factorial Calculator Does
This factorial calculator finds n! ("n factorial") for any non-negative integer you enter. The factorial counts how many ways you can arrange n distinct items in order, which makes it a building block for permutations, combinations, and probability problems.
It is useful for students learning combinatorics, anyone working with binomial coefficients or Taylor series, and people checking homework or programming output. Just type a whole number and the tool returns the exact result, including the answer for 0! and 1!.
How Factorial Works: The Formula
A factorial is the product of every positive integer from 1 up to n. Written out:
n! = n x (n - 1) x (n - 2) x ... x 3 x 2 x 1
By definition, 0! = 1. This is not a special exception invented for convenience; it is the only value that keeps formulas like the number of arrangements of an empty set, and the combination formula nCr = n! / (r!(n - r)!), consistent. The factorial is only defined for non-negative integers, so negative numbers and fractions have no ordinary factorial.
- 0! = 1
- 1! = 1
- Each step adds one more factor: n! = n x (n - 1)!
Worked Example: 5! Step by Step
Suppose you want 5!. Multiply the integers from 1 to 5:
5! = 5 x 4 x 3 x 2 x 1 = 120
You can build it gradually: 1 x 2 = 2, then 2 x 3 = 6, then 6 x 4 = 24, then 24 x 5 = 120. So 120 different orderings exist for five distinct objects. For a slightly larger case, 7! = 7 x 720 = 5,040, because 6! = 720 and 7! = 7 x 6!.
Why Factorials Grow So Quickly
Factorials increase far faster than exponential growth because each new term multiplies by a larger number. This rapid growth is the single most important thing to understand when using the result.
A few reference values show the jump in scale:
- 5! = 120
- 10! = 3,628,800
- 13! = 6,227,020,800
- 20! = 2,432,902,008,176,640,000
Common Mistakes and Practical Tips
The most frequent error is forgetting that 0! = 1 and assuming it equals 0. Another is trying to take the factorial of a negative number or a decimal, which is undefined in basic math (the gamma function extends factorials, but that is a different tool).
When using a factorial in a combination or permutation, simplify before multiplying. For example, 100! / 98! is just 100 x 99 = 9,900, so you never need the full giant number. In programming, watch for integer overflow: standard 64-bit integers cannot hold values past 20!, so use arbitrary-precision types or floating point for larger inputs and expect rounding.
- Remember 0! = 1 and 1! = 1
- Factorials only apply to whole numbers 0 and above
- Cancel common terms in nCr and nPr instead of computing huge factorials
- Beware overflow above 20! in fixed-width integer code
Frequently asked questions
What is a factorial?
The factorial of a non-negative integer n, written n!, is the product of all positive integers from 1 to n. For example, 5! = 5 x 4 x 3 x 2 x 1 = 120.
What is 0! (zero factorial)?
By definition, 0! = 1. This convention makes formulas in combinatorics, such as those for permutations and combinations, work consistently.
Can I compute the factorial of a negative or decimal number?
The standard factorial is defined only for non-negative integers. Enter a whole number 0 or greater. Factorials of other values require the gamma function, which this calculator does not cover.
Why does a large n produce an inexact result?
Factorials grow very quickly, so beyond roughly n = 18 the exact integer exceeds standard precision and is shown in approximate form. Values above about n = 170 exceed the representable range entirely.