Modular arithmetic
Modular arithmetic is about remainders in division. For example, when you divide by , the remainder is . We write that as .
The word “modular” comes from the Latin modulus, meaning a small measure. So is like saying: “If you measure in chunks of , you have left over.”
The triple-bar equals sign means “congruent modulo.” The statement above reads: “ is congruent to modulo .” In practical terms, it means and leave the same remainder when divided by .
Modular properties
Even though is not the same as , you can still do many familiar algebra-like operations with congruences.
Here are three useful properties. For all three, assume:
In the examples, we’ll use , , , , and , so:
and
A key theme is that the modulus (the number after “mod”) must match. When two congruences share the same modulus, you can combine them using the operations below.
Addition
When and ,
if and
then
That last step is important. The number on the right side of is representing a remainder, so it should be written as a number less than the modulus. Since is more than , we replace with .
Subtraction
When and ,
if and
then
Here, is already less than , so no further simplification is needed.
This connects to a basic fact you’ll use often: when .
Multiplication
When and ,
if and
then
Again, we reduce the right-hand side to a remainder less than : since , we write .
Fermat’s little theorem
Here, is any prime number, and is a positive integer.
- The theorem applies when is prime and is not a multiple of .
- It says that if you raise to the power and divide by , the remainder is .
Example: The question below is from 2017 AMC 10B
An integer is selected at random in the range . What is the probability that the remainder when is divided by is ?
a.
b.
c.
d.
e.
Answer: D.
Notice that can be rewritten as . To connect this to Fermat’s little theorem, set , so the exponent is . That’s why is the key piece to analyze modulo .
Euler’s theorem
Euler’s theorem is a generalization of Fermat’s little theorem.
- For the theorem to apply, and must be coprime (they share no prime factors).
- is Euler’s totient function: it counts how many positive integers less than are coprime to .
For example, because there are numbers less than that are coprime to : , , , and .
Plugging in one of these coprimes gives:
In other words, the remainder of when divided by is .
Example: The question below is from 2024 AMC 10B
How many different remainders can result when theth power of an integer is divided by ?
a.
b.
c.
d.
e.
Answer: B.