Concepts158
Quadratic Residues
A quadratic residue modulo an odd prime p is any a for which x^2 β‘ a (mod p) has a solution; exactly half of the nonzero classes are residues.
MΓΆbius Function and Inversion
The MΓΆbius function ΞΌ(n) is 0 if n has a squared prime factor, otherwise it is (-1)^k where k is the number of distinct prime factors.
Divisor Function Sums
Summing the divisor function d(i) up to n equals counting lattice points under the hyperbola xy β€ n, which can be done in O(βn) using floor-division blocks.
Multiplicative Functions
A multiplicative function is an arithmetic function f with f(mn) = f(m)f(n) whenever gcd(m, n) = 1.
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).
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.
Sqrt Decomposition on Queries
Sqrt decomposition on queries (time blocking) processes Q operations in blocks of size about \(\sqrt{Q}\) to balance per-query overhead and rebuild cost.