Simple Introduction To Modular Arithmetic

Modular arithmetic, explained the way I would have liked to have learned it.
→ [preprint-e, preprint-p] ←1  Keywords: #integer-division #divisibility #modular-arithmetic #euclidean-algorithm

We define modular equivalence on the integers, and explain how to endow the set of equivalence classes modulo \(n\) with addition and multiplication. This is then used to provide a deeper understanding of the properties of congruences, and modular inverses (required for solving linear congruences).

The latter task (modular inversion) requires writing the greatest common divisor of two integers as a linear combination of said integers, leading us to explain—and implement in Python—the extended Euclidean algorithm. The code provided at the end of the manuscript is simplified to ease the explanation—a more complete version can be accessed here.

October 23, 2025. Got feedback? See the contact page.


  1. The -e is the version for reading on a screen, and -p is the version for reading on paper. The latter—which is the one I actually proof-read, because it is much easier to do so on paper—contains footnotes (instead of endnotes), and no colouring of links. But the former—which has coloured links and (hyperlinked) endnotes—is much easier to read on a screen, and hence I offer it too.↩︎