Concepts4
⚙️AlgorithmIntermediate
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.
#modular arithmetic#modular inverse#fermats little theorem+12
∑MathIntermediate
Lucas' Theorem
Lucas' Theorem lets you compute C(n, k) modulo a prime p by working digit-by-digit in base p.
#lucas theorem#binomial coefficient modulo p#prime power modulus+12
∑MathAdvanced
Primitive Roots
A primitive root modulo n is a number g that cycles through all units modulo n when you repeatedly multiply by g, so its multiplicative order equals \(\varphi(n)\).
#primitive root#multiplicative order#euler totient+10
∑MathAdvanced
Linear Recurrence
A linear recurrence defines each term as a fixed linear combination of a small, fixed number of previous terms.
#linear recurrence#matrix exponentiation#kitamasa+12