Expand description
Modular arithmetic, CRT, discrete logarithm, and visualization.
Structs§
- Clock
Glyph - Clock
Visualization - Renders residue classes as positions on a circle (clock face).
- Pattern
Cell - Residue
Pattern - Render multiplication tables mod n as glyph grids.
Functions§
- chinese_
remainder_ theorem - Chinese Remainder Theorem: given residues[i] and moduli[i], find x such that x ≡ residues[i] (mod moduli[i]) for all i. Returns None if the system is inconsistent.
- discrete_
log - Baby-step giant-step discrete logarithm: find x such that base^x ≡ target (mod modulus).
- mod_
inverse - Modular inverse of a mod m, if it exists (gcd(a, m) == 1).
- mod_pow
- Modular exponentiation: (base^exp) mod modulus.
- primitive_
roots - Find all primitive roots modulo n (if they exist). Primitive roots exist iff n is 1, 2, 4, p^k, or 2*p^k for odd prime p.