Concepts15
Modular Arithmetic Pitfalls
Modular arithmetic is about working with remainders, but programming languages often return negative remainders, so always normalize with (a % MOD + MOD) % MOD.
Burnside's Lemma
Burnside's Lemma says the number of distinct objects up to a symmetry group equals the average number of objects fixed by each symmetry.
Lucas' Theorem
Lucas' Theorem lets you compute C(n, k) modulo a prime p by working digit-by-digit in base p.
Discrete Logarithm
The discrete logarithm problem asks for x such that g^x β‘ h (mod p) in a multiplicative group modulo a prime p.
Permutations and Combinations
Permutations count ordered selections, while combinations count unordered selections.
Euler's Totient Function
Euler's Totient Function Ο(n) counts how many integers from 1 to n are coprime with n.
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).
Euler's Theorem
Eulerβs Theorem says that if a and n are coprime, then a raised to the power Ο(n) is congruent to 1 modulo n.
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).
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.
Extended Euclidean Algorithm
The Extended Euclidean Algorithm finds integers x and y such that ax + by = gcd(a, b) while also computing gcd(a, b).