Concepts8
Derangements
A derangement is a permutation with no element left in its original position, often written as !n or D(n).
Inclusion-Exclusion Principle
The Inclusion-Exclusion Principle (IEP) corrects overcounting by alternately adding and subtracting sizes of intersections of sets.
Stars and Bars
Stars and Bars counts the ways to distribute n identical items into k distinct bins using combinations.
Modular Arithmetic Basics
Modular arithmetic is arithmetic with wrap-around at a fixed modulus m, like numbers on a clock.
Modular Inverse
A modular inverse of a modulo m is a number a_inv such that a × a_inv ≡ 1 (mod m).
Fermat's Little Theorem
Fermat's Little Theorem says that for a prime p and integer a not divisible by p, a^{p-1} ≡ 1 (mod p).
Fast Exponentiation
Fast exponentiation (binary exponentiation) computes a^n using repeated squaring in O(log n) multiplications.
Chinese Remainder Theorem
The Chinese Remainder Theorem (CRT) reconstructs an integer from its remainders modulo pairwise coprime moduli and guarantees a unique answer modulo the product.