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
∑MathAdvanced
Discrete Logarithm
The discrete logarithm problem asks for x such that g^x ≡ h (mod p) in a multiplicative group modulo a prime p.
#discrete logarithm#baby-step giant-step#pollard rho dlp+12
∑MathIntermediate
Modular Arithmetic Basics
Modular arithmetic is arithmetic with wrap-around at a fixed modulus m, like numbers on a clock.
#modular arithmetic#mod#modulo c+++12
∑MathIntermediate
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).
#fermat's little theorem#modular inverse#binary exponentiation+11