Factorials: How to Calculate n Factorial

Calculates n! = n × (n−1) × … × 1, where n is an integer of 0 or greater. By definition 0! is 1.

The factorial n!n! is the product of every integer from 1 up to nn.

n!=n×(n1)××2×1n! = n \times (n-1) \times \cdots \times 2 \times 1

Factorials count arrangements. There are nn ways to fill the first slot in a row, n1n - 1 ways to fill the second from what is left, and so on down the line. Multiply those choices together and you get exactly n!n!, the number of ways to order nn distinct objects.

Example

Take n=5n = 5.

5!=5×4×3×2×1=1205! = 5 \times 4 \times 3 \times 2 \times 1 = 120

Equivalently, five objects can be lined up in 120 different orders.

Notes