MATH CALCULATOR
Factorial Calculator
Calculate the factorial of a non-negative integer and understand the n! formula, examples, zero factorial, and common mathematical uses.
What is a factorial?
The factorial of a non-negative integer n is the product of all positive integers from 1 through n. It is written n! and is widely used in permutations, combinations, probability, counting, series, and discrete mathematics.
Factorial formula
n! = n × (n − 1) × (n − 2) × ... × 2 × 1. The recurrence form is n! = n × (n − 1)! for n ≥ 1.
Worked examples
5! = 5 × 4 × 3 × 2 × 1 = 120.
3! = 3 × 2 × 1 = 6.
0! = 1 by definition, which keeps standard counting formulas consistent.
Factorials in combinations
Factorials are used in the combination formula C(n,r) = n! / [r!(n−r)!] and the permutation formula P(n,r) = n! / (n−r)!, when the inputs satisfy the relevant conditions.
Input limits and numerical precision
This calculator accepts integers from 0 through 170. Factorials grow extremely quickly; values near the upper limit can exceed ordinary JavaScript number precision even when the magnitude is representable. Use arbitrary-precision software when exact very-large results are required.
Factorial FAQ
Can factorials be negative?
Ordinary integer factorial notation is defined for non-negative integers. This calculator therefore rejects negative inputs.
Why is 0! equal to 1?
It is the standard mathematical convention that makes recurrence and counting formulas work consistently.
Where are factorials used?
Common applications include permutations, combinations, probability, counting problems, power series, and discrete mathematics.
Related calculators
Permutation & Combination Calculator · Probability Calculator · Scientific Calculator · All Calculators
Calculation context
The factorial of a non-negative integer n is the product of all positive integers from 1 through n, written n!. Factorials grow rapidly and are widely used in counting and probability.
What a factorial means
The factorial of a non-negative integer n, written n!, is the product of all positive integers from n down to 1. By definition, 0! equals 1.
Worked example
5! = 5 × 4 × 3 × 2 × 1 = 120. Factorials grow very quickly, which is why exact results can become large even for moderately sized inputs.
Where factorials are used
Factorials appear in permutations, combinations, probability and many discrete mathematics formulas. The calculator is intended for non-negative integer inputs unless the page explicitly supports another function.
Factorial FAQ
Why is 0! equal to 1?
The definition makes factorial-based counting formulas consistent, including the number of ways to arrange zero selected items.
Factorial calculation, step by step
The factorial of a non-negative integer n, written n!, multiplies every integer from n down to 1. It follows the recurrence n! = n × (n−1)! for n ≥ 1, with 0! = 1 as the base case. Factorials are defined here for whole numbers; a decimal input is not an ordinary integer factorial.
Worked example: arranging objects
Suppose four different books are placed in a row. There are 4 choices for the first position, then 3, then 2, then 1, so the number of arrangements is 4! = 4 × 3 × 2 × 1 = 24. If only two of five objects are selected and order matters, the permutation count is P(5,2) = 5!/(5−2)! = 5 × 4 = 20.
Factorials in combinations
When order does not matter, combinations use C(n,r) = n!/[r!(n−r)!]. For example, choosing 2 people from 5 gives C(5,2) = 5!/(2!3!) = 10 groups. This distinction—arrangement versus selection—is the key to choosing permutations or combinations.
Precision and limits
Factorials grow rapidly: 10! is 3,628,800, while 20! is already much larger. This page accepts values only from 0 to 170, but ordinary JavaScript numbers cannot represent every large integer exactly. If you need an exact factorial for a large n, use arbitrary-precision integer arithmetic rather than relying on a rounded floating-point result.
Factorial calculator FAQs
Why is 0! equal to 1?
It is the multiplicative identity convention that keeps the recurrence and counting formulas consistent, including the one way to arrange an empty set.
Can I calculate a factorial of 4.5?
Not with this integer-factorial calculator. Non-integer extensions use the gamma function and are a different calculation.
When do I use permutations instead of combinations?
Use permutations when order matters, such as ranking people; use combinations when only the selected group matters, such as choosing committee members.