Number operations
Denote by . Recall the notation " divides ", meaning . Also, the congruent notation (" is congruent to modulo "), which means . Modular arithmetic deals with relations under this modulo notation. Another name for modular arithmetic is "calendar arithmetic", e.g., implies that, if today is Sunday, then days from now will be Monday.
Prove that under modulo is an equivalence relation.
If and , then and
The above exercise allows us to have an easier time working in modular arithmetic. For instance, if we want to find the last digit of number , we could simply write and then we can raise both sides to the power of , which gives us . The last digit of this number is !
What is the last digit of ? Prove your answer.
📄️ Exponentiation
Now we may ask ourselves: How fast can we do these modular arithmetic operations? When we multiply two $n$-digit numbers, it is easy to see that a school multiplication method would give us $O(n^2)$ bit operations.
📄️ Inverse
The next operation we want to discuss is the inverse operation. The inverse of addition is subtraction, which can be done easily. But the concept of multiplicative inverse in modular arithmetic is less clear (for real numbers, the inverse of $x$ is simply $1/x$).