Compute n! = n × (n-1) × ⋯ × 2 × 1. Factorials count the number of ways to arrange n distinct objects.

Example

Expand and multiply a factorial. A factorial multiplies together every whole number from the given value down to one, and it counts the number of ways to arrange that many distinct items in order. Writing the product out in full before multiplying makes the pattern clear and shows how quickly factorial values grow as the input increases.

highlighted = computed this step

Step 1 — Set up

Start with the factorial.

5!5 !

Step 2 — Expand

Expand the factorial into factors.

5!=543215 != \hl{5} \cdot \hl{4} \cdot \hl{3} \cdot \hl{2} \cdot \hl{1}

Step 3 — Multiply

Multiply the first factors.

543=605 \cdot 4 \cdot 3 = \hl{60}

Step 4 — Result

State the factorial value.

5!=1205 != \hl{120}
factorial n! = n × (n-1) × (n-2) × ⋯ × 2 × 1 Special case: 0! = 1