Skip to main content

Module modular

Module modular 

Source
Expand description

Modular arithmetic, CRT, discrete logarithm, and visualization.

Structs§

ClockGlyph
ClockVisualization
Renders residue classes as positions on a circle (clock face).
PatternCell
ResiduePattern
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.