LOGBOOK

HELP

Quiz Entry - updated: 2026.07.14

What is the factorial function and how is it relevant to cryptography?

n! (n factorial) is the product of all positive integers from 1 to n, and it defines the size of permutation spaces — critical for understanding how large a block cipher's theoretical key space could be.

(2^n)! permutations vs the 2^n a key can select, log scale

* The permutation count (2ⁿ)! dwarfs the 2ⁿ permutations a key can actually select. *

Definition:

  • $n! = n \times (n-1) \times (n-2) \times \dots \times 2 \times 1$
  • $0! = 1$ (by convention)
  • Example: $5! = 120$, $10! = 3{,}628{,}800$

Cryptographic relevance:

  • A block cipher with $n$-bit blocks operates on $2^n$ possible values
  • The total number of possible permutations is $(2^n)!$
  • For AES ($n = 128$): $(2^{128})!$ is unimaginably large

Stirling's approximation for large $n$:

$$n! \approx \sqrt{2\pi n}\,\left(\frac{n}{e}\right)^n$$

For large $n$, computing $n!$ directly is impossible, but Stirling's formula gives a good approximation for the logarithmic (bit-length) calculations that matter in cryptography.

Go deeper:

From Quiz: KRYPTOG / Symmetric Cryptography | Updated: Jul 14, 2026