Skip to content
uencoder

Permutation

A permutation counts the ordered ways to choose k elements from n, P(n,k)=n!/(n-k)!; the full permutation count is n!.

Purpose

To count ordered selections, a foundation of combinatorics.

Mechanism

P(n,k) = n!/(n-k)! = n×(n-1)×...×(n-k+1). Full permutations P(n,n)=n!. Permutations with repetition P(n,k)=n^k. Circular permutations P(n,k)=(n-1)!. Generate all permutations with backtracking or Heap's algorithm.

Use cases

  • Permutation generation and enumeration
  • Password strength calculation
  • Scheduling and ordering problems
  • Probability computation

Examples

  • Input
    P(5,3)=5!/(5-3)!=60
    Output
    60

    Ordered arrangements of 3 out of 5

Common errors

Confusing permutations with combinations (ordered vs unordered)
Permutations are ordered (P), combinations unordered (C)

Related terms

Related tools

References