Home / Maths for AI / Symbols / Arithmetic and comparison

Factorial

Say it: "n factorial"

What it means

The product of all whole numbers from 1 to nn. By definition 0!=10! = 1.

Example

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

It grows extremely fast.

In code

import math
print(math.factorial(5), math.factorial(20))

Output

120 2432902008176640000

Where it appears in machine learning

Counting orderings and combinations, for example in probability.

Related symbols

Learn it properly in the free lesson Probability & Distributions, with practice questions that check your answers.