Modular Arithmetic is an extremely useful way of thinking about numbers. It can be used to calculate the last three digits of 20112011 by hand. The day of the week, the time of the day, and the flipping of a light switch are all based upon modular arithmetic. The day of the week is in mod7 (cycles in a period of 7), the time of the day is in mod24, and a light switch is either on or off; mod2.
Definitions
Two integers are congruent modulo n if their difference is a multiple of n. We write this as a≡b(modn)
For example, 36≡71(mod7), because 71−36=35, and 735=5.
We can alternatively write this as a−b=qn, for an integer q, or a=b+qn (by adding b to both sides). Notice that for any integers x and y, if x≡y(modn), x and y leave the same remainder when divided by n. This is sometimes used as another definition for modular arithmetic. Since modular arithmetic is only defined for integers, let all variables be integers unless otherwise specified.
Addition
Theorem 1: If a≡b(modn), then a+c≡b+c(modn).
If a≡b(modn), we know that a−b=qn for some integer q. This means (a+c)−(b+c)=a−b=qn, so a+c≡b+c(modn). ■
If we know that 123 leaves a remainder of 2 when divided by 11, and want the remainder when 127 is divided by 11, we can simply use Theorem 1: 123≡2(mod11)⟹123+4≡2+4(mod11), so 127≡6(mod11). A similar proof can be used to prove a stronger theorem:
Theorem 2: If a≡b(modn), and c≡d(modn), then a+c≡b+d(modn).
We know that a−b=qn for some integer q and c−d=rn for some integer r. Adding the equations gives (a+c)−(b+d)=qn+rn=(q+r)n. This means that the difference of a+c and b+d is a multiple of n, so a+c≡b+d(modn). ■
Theorem 2 can be generalized even further:
Theorem 3: If a1≡b1(modn), a2≡b2(modn), ⋯,ak≡bk(modn) then a1+a2+⋯+ak≡b1+b2+⋯+bk(modn).
By the definition of modulos, we get a1−b1=q1n,a2−b2=q2n,⋯,ak−bk=qkn. Adding these, we get
(a1+a2+⋯+ak)−(b1+b2+⋯+bk)=(q1+q2+⋯+qk)n,so a1+a2+⋯+ak≡b1+b2+⋯+bk(modn). ■
Theorem 3 can be used to solve the following problem:
Problem 1
Find the remainder when 123+234+32+56+22+12+78 is divided by 3
We know that 123≡0(mod3), 234≡0(mod3), 32≡2(mod3), 56≡2(mod3), 22≡1(mod3), 12≡0(mod3), and 78≡0(mod3). From Theorem 3, 123+234+32+56+22+12+78≡0+0+2+2+1+0+0≡5(mod3). 5 has a remainder of 2 when divided by 3, so 123+234+32+56+22+12+78 does too, and the answer is 2.
Subtraction
The same theorems hold for subtraction as well:
Theorem 4: If a≡b(modn), then a−c≡b−c(modn).
If a≡b(modn), we know that a−b=qn for some integer q. This means (a−c)−(b−c)=a−b=qn, so a−c≡b−c(modn). ■
Theorem 5: If a≡b(modn), and c≡d(modn), then a−c≡b−d(modn).
We know that a−b=qn for some integer q and c−d=rn for some integer r. Subtracting the equations gives (a−c)−(b−d)=qn−rn=(q−r)n. This means that the difference of a−c and b−d is a multiple of n, so a−c≡b−d(modn). ■
Multiplication
Similar theorems hold for muliplication as well, but the proofs are different.
Theorem 6: If a≡b(modn), then ac≡bc(modn).
If a≡b(modn), we know that a−b=qn for some integer q. This means ac−bc=qcn, so ac≡bc(modn). ■
There is also another proof of this:
We know that c statementsa≡b(modn),a≡b(modn),⋯,a≡b(modn)
From Theorem 3, we get c "a"sa+a+a+a+⋯+a≡c "b"sb+b+b+b+⋯+b
or ac≡bc(modn). ■
Theorem 7: If a≡b(modn), and c≡d(modn), then ac≡bd(modn).
We repeatedly use Theorem 6: Since a≡b, ac≡bc, and since c≡d, bc≡bd. Therefore, ac≡bc≡bd, or ac≡bd(modn). ■
Theorem 8: If a1≡b1(modn), a2≡b2(modn), ⋯,ak≡bk(modn) then a1a2⋯ak≡b1b2⋯bk(modn).
We repeatedly use Theorem 7: Because a1≡b1(modn), a2≡b2(modn), we get
a1a2≡b1b2(modn)
We also know a3≡b3(modn), so
a1a2a3≡b1b2b3(modn)
Also, a4≡b4(modn), so
a1a2a3a4≡b1b2b3b4(modn)
Continuing to do this will give
a1a2⋯ak≡b1b2⋯bk(modn)■
Problem 2:
Find the remainder when 124⋅134⋅23⋅49⋅235⋅13 is divided by 3.
In Problem 1, manually adding the numbers up wouldn't take that much time, though the modular arithmetic solution is faster. However, in Problem 2, multiplying the numbers would be very tedious. Instead, we use Theorem 8: We know that 124≡1, 134≡2, 23≡2, 49≡1, 235≡1, and 13≡1. Therefore, from Theorem 8,
124⋅134⋅23⋅49⋅235⋅13≡1⋅2⋅2⋅1⋅1⋅1≡4≡1(mod3)
so the product leaves a remainder of 1 when divided by 3.
Exponentiation
Note that a corollary of Theorem 8, when a1=a2=⋯=ak and a1=a2=⋯=ak, is that
Theorem 9: If a≡b(modn), then ak≡bk(modn).
One might expect the following theorem to hold:
If x≡y(modn), then ax≡ay(modn).
However, taking n=3, a=2, x=2, and y=5, we get 2≡5(mod3), but 22≡1≡2≡25(mod3).
Problem 3: What is the remainder when 2312345 is divided by 22?
From Theorem 9, since 23≡1(mod22), 2312345≡112345≡1(mod22), so 2312345 leaves a remainder of 1 when divded by 22.
Problem 4: Find the last three digits of 240
240==≡≡(210)4102442445762(mod1000) We can write 5762 as (500+76)(500+76)==≡≡250000+2∗500∗76+76∗76250000+76000+57760+5776776(mod1000). Since 240 leaves a remainder of 776 when divided by 1000, its last three digits are 776.
And finally, we get to the problem mentioned in the introduction:
Problem 5: Find the last three digits of 20112011
We know that 2011≡11(mod1000), so 20112011≡112011(mod1000). We can write 112011 as (10+1)2011 and use the Binomial Theorem to expand it. We get 112011==(10+1)2011(02011)10201110+(12011)10201011+⋯+(20102011)10112010+(20112011)12011
However, all powers of 10 above 102 are divisible by 1000, so are 0(mod1000). Therefore, we can reduce them to 0. All terms at the beginning are nullified, and we are left with
(20092011)10212009+(20102011)10112010+(20112011)12011=100⋅(22011)+10⋅(12011)+1⋅(02011)
because of the property that (20092011)=(22011), (20102011)=(12011), and (20112011)=(02011). We can write this as
100⋅22011⋅2010+10⋅2011+1≡=≡100⋅211⋅10+10⋅11+15500+110+1611(mod1000)■
This discussion board is a place to discuss our Daily Challenges and the math and science
related to those challenges. Explanations are more than just a solution — they should
explain the steps and thinking strategies that you used to obtain the solution. Comments
should further the discussion of math and science.
When posting on Brilliant:
Use the emojis to react to an explanation, whether you're congratulating a job well done , or just really confused .
Ask specific questions about the challenge or the steps in somebody's explanation. Well-posed questions can add a lot to the discussion, but posting "I don't understand!" doesn't help anyone.
Try to contribute something new to the discussion, whether it is an extension, generalization or other idea related to the challenge.
Stay on topic — we're all here to learn more about math and science, not to hear about your favorite get-rich-quick scheme or current world events.
Markdown
Appears as
*italics* or _italics_
italics
**bold** or __bold__
bold
- bulleted - list
bulleted
list
1. numbered 2. list
numbered
list
Note: you must add a full line of space before and after lists for them to show up correctly
Shall we make all Theorems a little more users friendly! a,b,α,β,c,mallintegers.a1≡b1(modm),a2≡b2(modm)....an≡bn(modm).Addition and SubtractionTheorem 1a±c≡b±c(modm)Theorem 2a1±a2±...±an≡b1±b2±...±bn(modm)MultiplicationTheorem 3aa1∗a2∗...∗an≡b1∗b2∗...∗bn(modm)Theorem 3ban≡bn(modm)
Easy Math Editor
This discussion board is a place to discuss our Daily Challenges and the math and science related to those challenges. Explanations are more than just a solution — they should explain the steps and thinking strategies that you used to obtain the solution. Comments should further the discussion of math and science.
When posting on Brilliant:
*italics*
or_italics_
**bold**
or__bold__
paragraph 1
paragraph 2
[example link](https://brilliant.org)
> This is a quote
\(
...\)
or\[
...\]
to ensure proper formatting.2 \times 3
2^{34}
a_{i-1}
\frac{2}{3}
\sqrt{2}
\sum_{i=1}^3
\sin \theta
\boxed{123}
Comments
Very good post, detailed and clear! Please fix that LaTeX in the middle (Thm. 6), though.
It's helpful, but it would be more helpful if you could write an 867-page article how to evaluate i(modj) for 0≤i=j≤1000.
Log in to reply
0<i=j≤10.
For those who would want such an article, see here. It is a very enlightening article if you read it all the way through.
And also CRT
Great job! It helps!
You wrote the same article in Aops, really good job anyway :D
What about Intermediate Modular Arithmetic? Brilliant Tecniques do not cover it
If a≡b(modn) implies a−b=qn where q and n are integers, then is it true that a≡b(modq) ?
Log in to reply
yes. Just use the definition.
I didn't knew a single word about Modular Arithmetic..!! Thanks to u for letting me know what is it.
cool!
@Akshaj Kadaveru Can you add this to the Modular Arithmetic Wiki? Thanks!
VERY nice !!!!!!!!!
Log in to reply
@HARSH SHrivastava -Which class are you in?
Log in to reply
I am in 9th (early admission.).In which class are you?
Log in to reply
Log in to reply
Thanks once again for a wonderful writeup. I've added parts of it, especially the example problems, to the Modular Arithmetic Wiki.
Shall we make all Theorems a little more users friendly!
a, b, α, β, c, m all integers.a1≡b1(modm), a2≡b2(modm)....an≡bn(modm). Addition and SubtractionTheorem 1 a±c≡b±c(modm)Theorem 2 a1±a2±...±an≡b1±b2±...±bn(modm) MultiplicationTheorem 3a a1∗a2∗...∗an≡b1∗b2∗...∗bn(modm) Theorem 3b an≡bn(modm)