Modular Arithmetic

Notation
Meaning

mnm \mid n

mm divides nn

mnm \nmid n

mm does not divide nn

nr(modm)n \equiv r (mod m)

m(nr)m \mid (n-r), that is, as mm divides nrn-r, nn and rr have the same remainder when divided by mm

x\lfloor x \rfloor

floor function: largest integer not larger than x

nmodmn mod m

(binary operator) remainder of nn when divided by mm (mm is called the modulus, which we assume here to be a positive integer). Equal to nmnmn-m \lfloor \frac{n}{m} \rfloor. Note that 0r<m0 \le r \lt m. In C, Python, Java, and pari-gp, it can be computed using using the % binary operator (applied to unsigned integers).

gcd(a,b)gcd(a,b)

gratest common divisor of aa and bb.

lcm(a,b)lcm(a,b)

least common multiple of aa and bb; equal to ab/gcd(a,b)ab/ gcd(a,b).

Zm\mathbb{Z}_m

set of equivalence classes modulo mm; slightly abusing the mathematical notation for equivalence classes, Zm={0,1,...,m1}\mathbb{Z}_m = \lbrace 0, 1, ..., m-1 \rbrace.

Examples

Last updated