MathDash_Book 2025
MathDash_Book 2025
as
“Mathematics is not about numbers, equations, or algorithms: it is about
understanding.”
hD
By the MathDash Team and Community
Daniel Sun, Akshaj Kadaveru, Dylan Yu
Contributors: Krithik (Monovariants and Invariants, Inequalities), John Z. (Tricks
about Squares and Cubes, Self-Similar Expressions, Section in Prime Factors &
Divisors, Interesting 3D Problems, Extensive LATEX help), Math645 (Modular
Arithmetic, Diophantine Equations, Orders), Sid (Stewart’s Thm, Complex
at
Contents
Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
Algebra . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
h
Self-Similar Expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
Geometry . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
as
Interesting 3D Problems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
Number Theory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
Practice Contests . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
MATHCOUNTS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
AMC 8 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
at
Geometry . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
Power of a Point . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
Stewart’s Theorem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
M
Number Theory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
Modular Arithmetic I . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
Practice Contests . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
MATHCOUNTS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
AMC 10 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
Algebra . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54
MathDash Contents 3
Cyclic Polynomials . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54
Complex Numbers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
Combinatorics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63
Linearity of Expectation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64
Recursion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68
Generating Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73
h
Geometry . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79
Ptolemy’s Theorem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79
as
Other Cyclic Quad Theorems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82
Incenter-Excenter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86
Number Theory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89
hD
Introduction to Diophantine Equations . . . . . . . . . . . . . . . . . . . . . . . . 89
Orders . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98
AIME . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105
at
USA(J)MO 106
Algebra . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106
Inequalities . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109
M
Combinatorics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 130
This is the official MathDash Guide to help you prepare for US-based math competitions, including
the MAA’s AMC–AIME–USA(J)MO progression and MathCounts.
We will provide a handout on each topic you may need to know, including walking through some
illustrative example problems to show how you can use that technique to solve problems. In order to
succeed, we suggest that you:
1. Preview the handout materials at your level (check the rating range) before attempting the
problems, ensuring that the relevant materials are fresh on your mind.
h
2. Clarify anything that is confusing with peers or with a coach using the pre-contest chat
3. Practice solving problems using timed contests on MathDash ← this is where you will spend the
as
bulk of your time. This is “exercise” for your mental muscles
5. Chat and discuss your ideas about problems with peers and coaches to refine your intuition.
hD
Every single practice problem should be “solvable” using techniques previously covered at some point
in this guide. That doesn’t mean you should expect to get a perfect score! Just knowing the
techniques is the first step. What we really need to work on together is the actual problem-solving
process. We have selected the highest quality problems for you to train the most efficiently, and have
also created a fun way to train since you can gain rating and track your progress over time :)
Whether you are aiming for a perfect score or solving a few problems as a first-time taker, remember
that every bit of progress is valuable and is putting you ahead of the field.
This is a LIVING document that will be updated as you request more modules. Submit any
M
requests for training topics to [email protected]. With your help and feedback, we hope this
guide will become one of the best ways to prepare for competition math!
John Z. Tricks about Squares and Cubes 5
Example 1
Given xy = 10, x + y = 20, and x > y, find x and y.
Z.
Solution. Note that if you subtract (x − y)2 from (x + y)2 using the right-hand side of theorem 1,
we get (x + y)2 − (x − y)2 = 4xy. We use this to find x − y from x + y and xy, and then solve the
system involving x − y and x + y.
hn
We substitute x + y = 20 and xy = 10 and then rearrange the equation:
√ √
202 − (x − y)2 = 4(10) =⇒ (x − y)2 = 360 =⇒ x − y = 360 = 6 10.
√
Note that it’s positive since x > y. Now, solving the system x + y = 20 and x − y = 6 10, we get
√ √
x = 10 + 3 10, y = 10 − 3 10 . ■
Jo
Optional: Graphic Proof of Theorem 2. It is trivial by expanding the right-hand side, but there’s a
more graphical way:
x
x−y
y x
y
x−y
1
Thanks to Steve for reminding me to add something like example 7 and doing it for me, even though he made
some typos. In addition, thanks for Krithik for corrections of various errors.
John Z. Tricks about Squares and Cubes 6
Note that x2 − y 2 is the area of the larger square minus the smaller one, which, if we want an
alternative representation, could be broken down into 2 parts, as shown by the dashed line. The
upper rectangle’s area is (x − y) · x and the lower rectangle’s area is y · (x − y). Adding these areas
together and factoring out x − y gives (x + y)(x − y).
Example 2
q √ q √
Calculate 10 − 51 + 10 + 51.
Solution. First, let the 2 terms be a and b respectively. Note that if we calculate ab it is easy because
after we combine the square roots, we can apply the difference of squares formula. Note that ab also
applies in the expansion of (a + b)2 , so what’s missing now is a2 + b2 which is also trivial to calculate.
Adding these together and taking the square root gives the desired result.
Z.
So let’s do it:
q √ q √ q √ √ q
√ 2 √
ab = 10 − 51 10 + 51 = (10 − 51)(10 + 51) = 102 − 51 = 49 = 7
√ √
a2 + b2 = 10 − 51 + 10 + 51 = 20
q √ √ √
a + b = (a + b)2 = a2 + 2ab + b2 = 20 + 14 = 34 . ■
hn
Example 3
Find the number of the prime factors of 232 − 1.
2 2
Solution. Note that 232 −1 = 232 −132 = (216 ) −(116 ) = (216 +116 )(216 −116 ) = (216 +1)(216 −1),
and then you can apply this in the second term in the result repeatedly, until it becomes (2+1)(2−1).
This means the factorization is
Jo
After checking that those are indeed prime and ignoring the 1, our answer is 5 . ■
Remark. If you want to cheat by writing a program to do this with C++ don’t forget long long.
Note how it’s impossible to do this if we just bash and calculate 232 − 1 directly, which is around 4e9.
Example 4
Given that x + 1
x
= 3, find x2 + 1
x2
.
Solution. Note how x · x1 = 1, so we try squaring x + x1 , and then subtracting some stuff to get the
expression we want.
1 2 1 1 1
x+ = x2 + 2x + 2 = x2 + 2 + 2 = 9
x x x x
It follows that the answer is 7 . ■
John Z. Tricks about Squares and Cubes 7
Example 5
If a + b = 1 and a2 + b2 = 3, find a4 + b4 .
Solution. Since we have a + b and a2 + b2 , we square the former and subtract the latter because
(a + b)2 = (a2 + b2 ) + 2ab =⇒ 1 = 3 + 2ab and ab = −1. Squaring (a2 + b2 ) gets us
a4 + 2a2 b2 + b4 = a4 + b4 + 2(ab)2 = a4 + b4 + 2, and since a2 + b2 = 3, that is equal to 9, giving
us a4 + b4 = 7 . ■
Definition 1 (Factoring)
In the rare case that you don’t know, factoring means to write something as a product of a
bunch of simpler expressions that cannot be written as products.
Example 6
Factor 4x2 − 9.
Z.
Solution. By difference of squares, we get (2x − 3)(2x + 3) . ■
hn
Note that there are a lot of ways in which these formulas can be applied. The above are just a
few of them.
Those are less commonly used but are very very elegant.
Solution. We have (a + b)2 = 25, hence a2 + 2ab + b2 = 25 so 2ab = −10, and ab = −5. Thus,
a3 + b3 = (a + b)(a2 − ab + b2 ) = 5 · ((a + b)2 − 3ab) = 5 · (25 − 3 · 5) = 50 . ■
John Z. Tricks about Squares and Cubes 8
A Trick Question
Example 8
Factor a6 − b6 .
a6 − b 6
2 2
= (a3 ) − (b3 )
= (a3 − b3 )(a3 + b3 )
= (a + b)(a2 − ab + b2 )(a − b)(a2 + ab + b2 )
Z.
a6 − b 6
3 3
= (a2 ) − (b2 )
= (a2 − b2 )(a4 + a2 b2 + b4 )
= (a + b)(a − b)(a4 + a2 b2 + b4 )
Note how they don’t match up. The fact is that a4 + a2 b2 + b4 is still factorable, and it’s
(a2 − ab + b2 )(a2 + ab + b2 ). If you’re not convinced, multiply it out! The answer is therefore
hn
(a + b)(a2 − ab + b2 )(a − b)(a2 + ab + b2 ) from the first approach. Please note that a2 ± ab + b2
is not factorable.
Cube of a Binomial
Jo
The following is less used but are sometimes still helpful in some problems:
We have
1
3
3 1 1
1
1 √ √ 3 √
x+ = x + 3 + 3x x+ = x3 + 3 + 3( 3) = 3 = 3 3.
x x x x x
Jo
Trying to solve this with complex numbers would be a headache. Another remark is that if you
can’t find anything useful, try squaring and cubing some expressions and it might work out. If you
have time, experimenting with stuff never hurts.
2
Added 2/9/25, Code credit: https://tex.stackexchange.com/questions/644612/ab-whole-cubed-in-l
atex/644709#644709
3
From https://www.youtube.com/watch?v=9Syoo5hq8_w, family member on YouTube the other day
John Z. Tricks about Squares and Cubes 10
Z.
Fun Sum, 1200
a
Focus on Problem 5, 1 ∼ 4 are trivial, 6 is tricky
b
Marginally related, make sure you know Complete the Square before proceeding, only one step involves
stuff in this chapter
c
Focus on last problem
hn
Jo
John Z. Self-Similar Expressions 11
Self-Similar Expressions
by John Z.
Note: This isn’t really used often. Only a handful of problems require it, and this chapter is largely
optional.
Self-Similar Expressions
The trick with evaluating self-similar expressions is to find the part that is the same as original, let
the expression be x, make an equation and solve for x.
Example 1
Calculate
v
u
u
u
u
u
u
u2 +
v
u
u
u
t
2+
v
u
u
t
2+
s
2+
r
2+
q Z.
2+
√
2 + ···
hn
t
Note that the square roots just keep nesting, and it will be impossible to evaluate this infinitely by
hand. However, note that the magenta box is essentially the original (red box), and if we let x equal
to this amount, we can re-write the expression as
Jo
√
x= 2+x
This trick works not only on fractions! In fact, here’s another similar (pun intended) question that
involves fractions instead of square roots:
John Z. Self-Similar Expressions 12
Example 2
Calculate
3
3
2+ 3
2+ 3
2+ 3
2+ 3
2+ 3
2+
..
.
Z.
3
x=
2+x
(2 + x)(x) = 3
x2 + 2x − 3 = 0
(x + 3)(x − 1) = 0
Clearly this is positive, so x = 1 . ■
hn
Example 3
s
√
r q
Calculate 2+ 22 + 24 + 28 + · · ·.
Jo
s s
√ √ √
r q r q
Note that if you multiply 1+ 1+ 1+ 1 + · · · by 2, you get 2+2 1+ 1+ 1 + · · ·.
Now the 2 to the left of the inner square root can beswritten inside the inner sqrt by multiplying the
√
r q
stuff inside the square root by 2 , and that becomes 2 + 22 + 22 1 + 1 + · · ·. Now the 22 can
2
go into the inner-inner square root and become 24 and so on. Therefore,
v
u s
u r
√ √
r
u q √ q
1 + 1 + 1 + ··· 22 24 + 28 + · · ·
u
2 t1 + = 2+ +
.
John Z. Self-Similar Expressions 13
Summary
Z.
The main idea is that you need to find the sub-expression that is same with the original,
let the thing you need to calculate be x, and then write an equation and solve for it.
Sometimes more sophisticated tricks are needed.
Interesting 3D Problems
by John Z.
https://mathdash.com/contest/3d-geometry-mathcounts-chapter-target-level
ALL diagrams prepared with Asymptote. No raster graphics is included so the file is super small.
Volume Formulas
The volume of a prism or cylinder is the area of the base times the height.
For pyramids or cones, take the volume of the prism or cylinder with the same height and base
Z.
area and divide by 3.
Now try problem 8 in the pset. To find BCHE, try to use Pythag to get F B and multiply by
BE.
Solution. The solution for this kind of stuff, if there’s no “groove” faces that can’t be seen from the
outside at a perspective, is to consider sides from the front and back (which should be the same),
left and right (which should be the same), and top and bottom (which should be the same).
Top view: Front view:
There are 4 square units in here. There are 4 square units in here.
John Z. Interesting 3D Problems 15
Right view:
Now, try Problem 1 and 3 in the PSet. For problem 3 is is not made up of a bunch of cubes
but the process is similar — get surface area from left + right, top + bottom, front + back. For
left & right try not to bash.
Example 2
Z.
Find the surface area of this figure below. The side length of each cube is 1 unit.
hn
Solution. Let us go with our routine method; however, we will soon find that if we count using that
method, the faces outlined with red below are the faces that will NOT be counted. Try imagining
something spraying paint from the top, left, right, front, and back, and then you’ll find that those
Jo
Therefore, in addition to our regular method we need to add 2. From the front we have 4 squares;
from the right we have 6 squares; from the top we have 4 squares, as usual. Muliplying each of those
by 2, adding them together and adding 2 we get 30 units2 as our answer.
Another way to think about this This example is basically the same as the last example but with
an extra cube at the place with crazy highlighting. You can think of it as the bottom yellow surface
John Z. Interesting 3D Problems 16
begin lifted up, and while dragging the yellow surface up, the four magenta “supporting” surfaces
appeared out of thin air.
So the yellow face just moved up without changes in area but the 4 lateral faces were new. Therefore
the surface area of example 2 is just 4 more than that of example 1. 26 + 4 = 30 so this is correct.
With that in mind, let us try another problem using this shortcut:
Z.
Example 3
A rectangular prism has a surface area of 80. Now, a smaller prism with base perimeter 7 and
height 3 is stacked on the top base of the rectangular prism. Calculate the percent increase in
surface area.
Solution. The base of the smaller prism that overlaps the rectangular prism’s base gets “moved up”
to the other base of smaller prism. To support it the lateral surface area of the smaller prism is the
hn
part increased. The answer is 7·3
80
· 100% = 26.25%.
Body Diagonal
Jo
In a cube, a segment connecting the two opposite vertices is known as the body diagonal, also
known as a space diagonal. For a cube with side length s, the length of the body diagonal is
John Z. Interesting 3D Problems 17
√
s 3.
Example 4
Find the volume of a cube with body diagonal 5.
√
Solution. First, we find the side length by dividing 5 by 3 to undo the body diagonal formula, so
√
√ √ 2 √ 125 · 3
we get √5
3
= 5 3 3 . Now we cube it to get our answer: 5 3 3 = 125·327
3
= .
9
Z.
In the cube ABCDEF GH with opposite vertices C and E, J and I are the midpoints of edges
F B and HD, respectively. Let R be the ratio of the area of the cross-section EJCI to the
area of one of the faces of the cube. What is R2 ?
F
hn
H
G
J
A I
B
D
Jo
Do this in problem 5 of the problem set before coming here to read the solution.
Scaling
Example 6
The surface area of a sphere is three times of that of a sphere of radius 1. Find the former
sphere’s volume.
Solution. The formula for surface area of a sphere is 4πr2 , so the surface area scales quadratically
as the side length. This means that if you scale the side length by a factor of s, the surface area will
scale by a factor of s2 . Since the surface area is scaled by a factor of 3, the radius is scaled by a side
√ √
length of 3. Therefore the new radius is 3 and by the formula 34 πr3 , the radius is
4 √ 3 4 √ √
π( 3) = π(3 3) = 4π 3.
3 3
√
Z.
Hence, the volume of the former sphere is 4π 3.
Generally if you scale the shape by a factor of s, 2-dimensional measures like surface area will
scale by a factor of s2 and 3-dimensional measures like volume will scale by a factor of s3 4 .
In this section we are only covering basic shapes instead of the calculus stuff.
and that of a rectangle around one of its sides is a cylinder. We can add and subtract those things
to get the solid of revolution of other shapes.
Example 7
√
Find the volume of the solid of revolution of triangle ABC with side lengths 5, 7, and 116
around the line through A perpendicular to BC.
A
√
116
5
B 7 C
Solution. First, realize that the solid of revolution is the solid of revolution of △AOC minus the
solid of revolution of △AOB.
4
Except if the shape is a fractal. See https://www.youtube.com/watch?v=gB9n2gHsHN4. A lot of people think
fractals are self-similar shapes, while some kids only heard it in a song in Frozen.
John Z. Interesting 3D Problems 19
A
√
116
5
O B 7 C
Now notice that △AOB has a 5 in it so it might be a 3–4–5 triangle. Indeed it is! If OB = 3 and
AO = 4, we can see that OC 2 + AO2 = (7 + 3)2 + 42 = 116 = AC 2 .
This is trivial after. First we find the volume of the solid of revolution of △AOC around AO which
is a cone with OC as the radius and AO as the height. That volume is 31 π(7 + 3) · 42 = 160π 3
. Now
we find that of △AOB which is OB as radius and AO as height, so 3 π(3) · 4 = 12π. Subtracting
1 2
124
the latter from the former gives for our volume of the solid of revolution.
π
Z.
Now try problem 2 in the pset. The line revolved around is different but the method is the
same.
Solution. The distance between the centers plus the radii would be the largest. If you’re skeptical,
here’s a demonstration in 2D with different coordinates than the problem:
Jo
√ √
Now our answer is 82 + 12 + 22 + 1 + 2 = 3 + 69.
Q ?
1 4 6
3 5 Q
The net on the left folds to the right. Find the number for ?.
Solution. From imagination we know that 6 is red and 5 is yellow. Note that the yellow and the
desired surface do not share any corners; however, 5 shares a corner with all of the faces except 1 so
Z.
we know 1 is the answer.
Q ?
1 4 6
3 5 Q
hn
2
com/wiki/index.php?title=2023_AMC_8_Problems/Problem_17.
Solution. There are 4 edges in each direction (illustrated with different colors):
John Z. Interesting 3D Problems 21
Z.
Try the Problems
MATHCOUNTS Chapter Target Level 3D Geometry by Akshaj
hn
Jo
MathDash Prime Factors and Divisors 22
h
We know that the prime numbers are 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, . . . .
as
60 = 2 × 2 × 3 × 5 = 22 × 3 × 5
It turns out that this is the only way to write 60 as the product of prime numbers! We call this
hD
the prime factorization of 60. In general, each number N can be written in the form
Example 1
at
Solution: Multiplying this number out and then trying to find primes that divide it would take a
long time! Let’s instead do this by finding the prime factorization of each product in the multiplication.
M
10! = 10 × 9 × 8 × 7 × 6 × 5 × 4 × 3 × 2 × 1
= (2 × 5) × (32 ) × (23 ) × 7 × (2 × 3) × 5 × 22 × 3 × 2 × 1
= 28 × 34 × 52 × 7
Definition 1
The divisors of N are the positive integers d for which N is divisible by d. We use the notation
d | N to mean that d is a divisor of N , or N is divisible by d, or d divides N .
MathDash Prime Factors and Divisors 23
Example 2
Find all of the divisors of 60.
Solution: How can we find all of the divisors of a number? Well, we could try each of the 60
numbers from 1 through 60 and see if they evenly divide into 60. This would take a long time though
— so let’s search for a quicker solution.
In the case of N = 60, one trick we can use is the fact that if d | N , then (N/d) | N as well!
(For example, 2 is a divisor of 60 — so 60 ÷ 2 = 30 is also a divisor of 60). This is because the
divisors come in pairs that multiply to N = 60.
h
√
All we need to do is find all of the divisors of 60 that are less than 60 — and then calculate
60 ÷ d for each divisor to get the rest of them!
√
as
Since 60 ≤ 8, we can check d = 1, 2, · · · , 8 and see that 1, 2, 3, 4, 5, 6 are all divisors of 60 -
and then their pairs are 60
1
, 60
2
, 60
3
, 60
4
, 60
5
, 60
6
— giving us the 10 divisors
√
hD
How do we know that there are no more? Well, if d > 60 and d is a divisor of 60, then (60/d)
√
is also a divisor of 60, and 60 ≤ √6060 = 60. So, we would have found 60 in our search already —
d √ d
since we checked all divisors less than 60 — and thus have found d because we counted each of
those divisors as well as the divisors they are paired with.
Example 3
at
√
If we were to use the method in the previous example, we would have to check 90000 = 300
numbers to see if they were divisors of 90000. While better than checking 90000 values, this is still
a lot of numbers to check.
M
Let’s instead try to figure out what the prime factorization of a divisor of 90000 would look like
— maybe this will make them easier to count.
Theorem 2
If a is a divisor of b, then the exponent of a prime p in the prime factorization of a is less than
or equal to the exponent of the same prime p in the prime factorization of b
Why is this true? Let’s think about the exponent of the prime p in the prime factorization of ab ,
which is an integer. We know that there are more factors of p in a than b — so the exponent of
p in the prime factorization of ab would be negative! (As an example, you can see that if p = 3,
MathDash Prime Factors and Divisors 24
a = 2 × 33 , and b = 22 × 32 , then ab would have a negative exponent for 3). This is not possible,
because the prime factorization of any positive integer has only non-negative exponents.
Now — to solve the original problem, let’s write 90000 = 9 × 104 = 32 × (2 × 5)4 = 24 × 32 × 54
Now that we’ve prime factorized 90000, what must the prime factorization of a divisor of 90000
look like? Well — from Theorem 2, we know that the exponent of 2 must be less than or equal to 4,
the exponent of 3 must be less than or equal to 2, and the exponent of 5 must be less than or equal
to 4.
Also — since 90000 has an exponent of 0 for every prime that isn’t 2, 3, 5 — we know that the
exponent in a divisor of 90000 of any prime that isn’t 2, 3, 5 must also be less than or equal to 0!
h
So, for d a divisor of 90000, we can write it’s prime factorization as d = 2□ 3□ 5□ 7□ 11□ · · ·
and we know:
as
• the exponent of 2 is either 0, 1, 2, 3, 4
Now all that remains is to count the divisors. There are 5 choices for the value of e0 , 3 choices for
the value of e1 , and 5 choices for the value of e2 . Each possible choice gives us a value for 2e0 3e1 5e2
that is one of the divisors of 90000. Since there are 5 × 3 × 5 = 75 ways for us to choose these
values, there are 75 divisors of 90000.
M
This is because there are e0 + 1 ways to choose the exponent of 2 in the divisor (any integer
from 0 through e0 inclusive), e1 + 1 ways to choose the exponent of 3, and so on.
MathDash Prime Factors and Divisors 25
Example 4
Three consecutive integers multiply to 29760. What is the middle integer?
Solution: Well, a first idea would be to let the integers be n, n+1, and n+2. We get n(n+1)(n+2) =
29760. This is pretty difficult to solve though — it is a cubic equation and we don’t really have a
good way to solve these.
Let’s use the fact that n is an integer to help us — perhaps we can try prime factorizing 29760.
We can immediately write 29760 = 10 · 2976. To prime factorize 2976, we can start by repeatedly
dividing it by 2 — 2976 = 2 × 1488 = 4 × 744 = 8 × 372 = 16 × 186 = 32 × 93.
h
Then, we see that 93 satisfies the divisibility test for 3 (it’s digits sum to a multiple of 3) — so
we can divide by 3 to get 93 = 3 × 31.
as
So, the overall prime factorization is 29760 = 10 · 2976 = 10 × 25 × 93 = 26 · 3 · 5 · 31.
Now, how do we figure out what n is? Well — we know that 31 is a divisor of n(n + 1)(n + 2).
Theorem 4
hD
If a prime number p divides a × b, then either p divides a or p divides b (or both). This is
because if p didn’t divide either a or b, then p would not be in the prime factorizations of a or
b, meaning that their product’s prime factorization wouldn’t have p in it.
than 31, then n > 60, which means n(n + 1)(n + 2) > n3 > 216000 — which is way too big. So,
this tells us that one of n, n + 1, n + 2 must be equal to 31.
If n = 31, then n + 2 = 33, but 11 is not in the prime factorization that we obtained — so 33
cannot be one of the terms. If n + 2 = 31, then n = 29, but 29 is not in the prime factorization
we obtained. So, we must have n = 30 — and we can confirm 30 × 31 × 32 has the same prime
M
h
A number is divisible by 11 if adding and subtracting the digits in alternating order gives a
number divisible by 11. For example, 3 − 6 + 3 = 0, and since 0 is divisible by 11, 363 is
divisible by 11.
Example 5
as
How many even perfect square divisors does 1000000 have?
hD
Solution: We will use the ideas from an earlier example — we can prime factorize 1000000 = 106 =
26 × 56 . Thus, the divisors are 2□ 5□ where each box is an integer from 0 through 6 inclusive. We
know that there are 7 × 7 = 49 total divisors — the question though is how many of these are even
and perfect squares?
For a number 2□ 5□ to be even, the exponent of two needs to be greater than 0. For it to be a
at
perfect square, we need both of the exponents to be even, so that they can be evenly divided into two
equal numbers. For example, 24 52 is a perfect square because it can be written as (22 × 5) × (22 × 5)
— which is because the exponents 4,2 are both even.
So, we need the exponent of 2 to specifically be an integer from 0 to 6 inclusive that is greater
than 0 and even — it can only be 2, 4, 6. And we need the exponent of 5 to be an integer from 0
M
Example 6
A number is in the form of 12A53B, where A and B are not necessarily distinct digits. The
number is divisible by 396. Find it.
Solution (Example and Solution contributed by John): Since there is no straightforward divisibility
rule for 396, we factorize it:
396 = 22 · 32 · 11,
John Z. Prime Factors and Divisors 27
which is also 4 · 9 · 11. Now we have to apply divisibility rules for 4, 9, and 11! A number is divisible
by 4 if its last two digits are divisible by 4. Since the last two digits are 3B, B must be 2 or 6.
• If B = 2, then the number will be 12A532. It has to be divisible by 9, and since 1+2+5+3+2 =
13 which leaves a remainder of 4 when divided by 9, A leaves a remainder of 5 when divided by
9, leaving A = 5 (125532) the only valid solution. Now we need to check if it’s divisible by 11.
Since 1 − 2 + 5 − 5 + 3 − 2 = 0 which is divisible by 11, we’re good with 125532.
• If B = 6, the number will be 12A536. Since 1 + 2 + 5 + 3 + 6 = 17 which leaves a remainder
of 8 when divided by 9, A has to leave a remainder of 1 when divided by 9. A = 1, giving us
121536. Now check if it’s divisible by 11. Since 1 − 2 + 1 − 5 + 3 − 6 = −8 and that is not
divisible by 11, the whole number isn’t, leaving this solution bad.
This leaves 125532 as the only possible number. ■
Z.
Problems w/ Factors
Definition 2
Let νp (a) equal the exponent of p in the prime factorization of a for non-zero a. Formally,
max{k
∈ N0 : pk | n} if n ̸= 0
νp (n) =
hn
∞ if n = 0,
The above equation basically means that νp (n) is the largest k such that pk is a factor of n.
Do not memorize them. If you have questions about why they work, ask in the chat.
Example 7
Find the number of factors of 300 that are also multiples of 12.
Solution. 300 = 22 · 3 · 52 and 12 = 22 · 3. We know that ν2 (x) = 2 and ν3 (x) = 1 because in both
situations there is an inequality for ≤ and ≥ of ν2 . For ν5 (x) you can choose it freely from 0 to 2,
so there are a total of 3 .
John Z. Prime Factors and Divisors 28
Example 8
Find the number of ordered triples (x, y, z) that are all divisors of 600 and the gcd(x, y, z) = 12.
Solution. 600 = 23 · 3 · 52 and 12 = 22 · 3. From here we know that min(ν2 (x), ν2 (y), ν2 (z)) = 2
and ν2 (x), ν2 (y), ν2 (z) ≤ 3. The sequences of ν2 can be one of the triples where each number is
either 2 or 3 but not all of them are 3, so there’s 7 cases for this. For ν3 we know that for all of
those numbers, the value of that is 1. For ν5 all of them have to be at most 2 but at least one of
them must be 0. Therefore since we see “at least” we use the principle of inclusion or exclusion, PIE.
There can be 9 cases when one of them is 0; there are 3 is two of them are 0; there are only 1 if all
three are 0. The cases for this part is 9 · 3 − 3 · 3 + 1 = 19. Multiplying that by the cases for ν2 we
get 19 · 7 = 133 as our answer.
Z.
Example 9 (2013 CMQQR / 3)
A positive integer n has the property that there are three positive integers x, y, z such that
lcm(x, y) = 180, lcm(x, z) = 900 and lcm(y, z) = n. Determine the number of positive
integers n with this property.
Solution (By Inferno2332). Obviously x, y, z can’t have any prime factors above 5, otherwise
lcm(x, y) or lcm(y, z) would be divisible by that prime factor. So let
hn
x = 2a1 3a2 5a3 , y = 2b1 3b2 5b3 , z = 2c1 3c2 5c3 .
ν2 (180) = ν2 (900) = 2,
Jo
Now move on to ν3 (n). Since ν3 (180) = ν3 (900) = 2, we can use the exact same reasoning to
find ν3 (n) can be 0, 1, 2.
Finally consider ν5 (n). Since ν5 (180) = 1 and ν5 (900) = 2, we have max(a3 , b3 ) = 1 and
max(a3 , c3 ) = 2. Since the first condition gives a3 ≤ 1, the second condition forces c3 = 2. Since
b3 ≤ 1, the only possibility for max(b3 , c3 ) is 2. Thus, ν5 (n) can only be 1.
To summarize, there are 3 choices for ν2 (n), 3 choices for ν3 (n), and 1 choice for ν5 (n), and thus
the answer is 9.
Last 2 contests written by John + testsolved by Samuel & Akshaj. They are relevant to the section
by John.
h
https://mathdash.com/contest-group/prime-factors-divisors-4
https://mathdash.com/contest-group/prime-factors-divisors-5
as
https://mathdash.com/contest/divisors-sprint
https://mathdash.com/contest/john-problem-1735000837735
https://mathdash.com/contest/divisor-problem
hD
at
M
sussususus Easy Modular Arithmetic 30
Disclosure & Credit This chapter is authored by sussususus and typeset by John Z. The appro-
priate level is AMC 8 / MathCounts for this chapter.
This chapter introduces the basics of modular arithmetic. Modular arithmetic is pretty common
s
in math competitions like MATHCOUNTS and the AMC, and it can help you solve many seemingly
intractable problems involving remainders!
su
This is for beginners, so there is no advanced content like Fermat’s Little Theorem and so on.
Example 1
u
Suppose it is midnight (0:00) right now. What time will it be 1000 hours from now? Give your
us
answer in 24-hour time.
Solution. To solve this problem, you can think of the time as a cycle that repeats every 24 hours.
Modular arithmetic helps us simplify this problem by focusing on the remainder after dividing by 24.
1000 divided by 24 is 41 remainder 16, so 1000 hours is the same as 41 full days and 16 leftover
ss
In the previous problem, we were working in modulo 24. This means we only care about the
remainders when divided by 24. When we add 1 hour to 23 hours, we go back to 0.
su
So in modulo 24, 25 is the same as 1, because they have the same remainder when divided by 24.
We say that 25 is congruent to 1, modulo 24. And this is written as 25 ≡ 1 (mod 24).
Example 2
What integer between 0 and 4 is congruent to 6782 (mod 5)?
One thing which we can do with a congruence like 6782 ≡ 2 (mod 5) is add the same thing to
both sides:
6782 + 3 ≡ 2 + 3 (mod 5)
sussususus Easy Modular Arithmetic 31
6782 − 3 ≡ 2 − 3 (mod 5)
6782 × 3 ≡ 2 × 3 (mod 5)
67823 ≡ 23 (mod 5)
However, we cannot do it for division. (The rule for division is a bit tricky, and we will not
introduce it here. For now just know that it’s illegal.)
s
In other words, when a problem asks for something (mod n), you can reduce each of the numbers
in the problem (mod n) first before doing arithmetic operations.
su
Example 3
Find the remainder when 9453 × 6824 × 6782 × 5675341 is divided by 5.
u
Solution. We can find that the four numbers in the product are congruent to 3, 4, 2, 1 (mod 5),
respectively. Thus, the original product is congruent to 4×3×2×1 = 24 (mod 5). So the remainder
is 4.
us
Some problems ask about the last digit or last two digits. Keep the following in mind:
Example 4
Find the last two digits of 9810 .
su
Solution. Basically we want 9810 (mod 100). Now let’s try reducing the number 98. Note that
98 ≡ −2 (mod 100). Yes, negative numbers are allowed and can be very useful.
Now raise both sides to the power of 10 to get 9810 ≡ (−2)10 (mod 100). And (−2)10 = 1024 ≡
24 (mod 100), so the answer is 24.
Sometimes, it can help to break a large exponent into multiple small exponents. This is particularly
helpful if a power of the original number is congruent to 1 or −1 (mod m).
sussususus Easy Modular Arithmetic 32
Example 5
Find the remainder when 7777 is divided by 48.
Solution. Unlike the previous problem you can’t reduce 7 any further. So how can we simplify this
problem?
The key thing to notice is that 72 = 49. This is congruent to 1 (mod 48). So we can write the
expression as
388
7777 = (72 ) · 7 = 49388 · 7
s
Now we can reduce it mod 48. This simply becomes 1388 · 7 (mod 48), so the answer is 7.
su
Try the Problems
https://mathdash.com/contest/mod-arithmetic-problemset
u
us
ss
su
MathDash MATHCOUNTS 33
MATHCOUNTS
by MathDash Community
https://mathdash.com/contests?tag=MATHCOUNTS
h
as
hD
at
M
MathDash AMC 8 34
AMC 8
by MathDash Community
https://mathdash.com/contests?tag=AMC+8
h
AMC 8 Full-length Mock Contests
as
https://mathdash.com/contests?tag=AMC+8
hD
at
M
MathDash Power of a Point 35
Power of a Point
by MathDash Team
https://mathdash.com/maps/map/power-of-a-point
h
X
A O
as D
hD
Theorem 1 (Power of a Point)
Given any circle with center O and radius R, and any point X inside that circle, we call
OX 2 − R2 the power of the point X with respect to the circle.
The theorem states that for any chord AB that goes through X, AX · XB is equal to the
negative of the power of the point X. Since this is constant, this means AX · XB = CX · XD.
at
Proof: Let’s define E to be the midpoint of chord AB, and draw some extra lines
B
M
E
X
A O
D
MathDash Power of a Point 36
We want to find the expression AX × XB. This is equal to (AE − EX)(BE + EX) = (AE −
EX)(AE + EX) = AE 2 − EX 2 . Now, since we have right triangles, let’s use the Pythagorean
Theorem!
h
There is another way to prove that AX · XB = CX · XD using similar triangles! We know that
⌢
∠AXC = ∠BXD, and ∠ACX = ∠DBX (because they both are half the measure of arc AD) —
so by Angle Angle Similarity, we know that △ACX ∼ △DBX.
as
CX BX
This tells us = which rearranges to AX · XB = CX · XD.
AX DX
Interestingly, Power of a Point doesn’t only hold for points inside the circle — let’s look at a case
where point X is outside of the circle!
hD
Figure 2: Power of a Point — XA · XB = XC · XD = OX 2 − R2
E
C
X O
at
A
M
The theorem states that for any chord AB that goes through X, XA · XB is equal to the
power of the point X. Since this is constant, this means OX 2 − R2 = XA · XB = XC · XD.
Where did the XE 2 come from, you may ask? Well — consider what happens if we move
C and D closer together (maintaining that CD intersects X). We still have that XC · XD =
OX 2 − R2 = XA · XB holds as we move C and D closer and closer together. When they meet
MathDash Power of a Point 37
each other, we still need CD to intersect X — this means that they will meet at point E! And so,
XE · XE = OX 2 − R2 = XA · XB giving us our result.
As an aside, maybe you will notice that we defined the ’power of a point’ to be the negative of
our earlier definition. We can keep this consistent using something called directed lengths — where
we consider XA = −1 · AX. If this is the case, then the above theorem holds whether or not X is
inside or outside of the circle!
h
This is a really powerful theorem that can help us solve a variety of questions.
as
Example 1
Two circles intersect at F and E. A line is drawn tangent to both circles at C and D, and EF
intersects CD at X. If XC = 4, and the radii of the circles are 10 and 8, find XD.
hD
D
C X
F
at
E
M
Solution: Power of a Point on the left circle tells us XC 2 = XF · XE. Power of a Point on the
right circle also tells us XD2 = XF · XE. So, XC 2 = XD2 — and since XC = 4, we must have
XD = 4 . The radii of the circles turns out to be a bit of a red herring!
Stewart’s Theorem
by Sid, Testsolved by Math645 and Carcool
https://mathdash.com/maps/map/stewarts
c b
d
B m D n C
a
Theorem 1
d
In a triangle cut by any cevian (refer to image above), man + d2 a = b2 m + c2 n or,
man + dad = bmb + cnc. This can be memorized by the mnemonic “A man and his dad put a
bomb in the sink.” Note that m is simply a − n, and vice versa, so you can solve the equation
Si
if you have every other value and either a, m, or n.
Proof: Applying Law of Cosines in △ABD at angle ∠ADB, and in △ACD at angle ∠CDA,
we get the following equations:
Example 1
In △ABC, we have AC = BC = 7 and AB = 2. Suppose that D is a point on line AB such
that B lies between A and D and CD = 8. What is BD? (2005 AMC 12B #6).
Solution: First, as we should in any geometry problem, we will construct a quick diagram.
8
7 7
A 2 B x D
Next, lets use Stewart’s Theorem to solve this problem. We get the equation:
d
2(2 + x)(x) + 72 (2 + x) = 72 x + 2(82 )
Simplifying, we get
Si
2x2 + 4x + 98 + 49x = 49x + 128
2x2 + 4x − 30 = 0
x2 + 4x − 15 = 0
By factorizing this equation, we get the solutions to be 3 and −5. Since the length can’t be negative,
we get that the answer to be 3 .
Theorem 2
If AD is an angle bisector, then d2 + mn = bc.
Theorem 3
b2 +c2 a2
If AD is a median, then d2 = 2
− 4
Note: These theorems are not necessary to memorize, as they can easily be derived from
Stewart’s theorem. However, by memorizing them it makes it much easier to solve problems relating
to Stewart’s theorem faster.
Sid Stewart’s Theorem 40
Example 2
In quadrilateral ABCD, BC = 8, CD = 12, AD = 10, and m∠A = m∠B = 60◦ . Given that
√
AB = p + q, where p and q are positive integers, find p + q. (2005 AIME I Problem #7).
Solution: We start by drawing a diagram. In the following diagram, note that we extend lines
BC and AD to intersect at point E.
D
12
10 C
8
d 60◦ 60◦
A x B
Si
After that, we draw a line from C parallel to line AD, with intersection point F.
D
12
10 F C
60◦ 60◦
A x B
Now, we can perform Stewart’s Theorem on △ECF . Since F C ∥ AB, △EBA ∼ △ECF . This
means that △ECF is also equilateral. Also, this means that AF = CF = 8 and DF = 10 − 8 = 2.
Now, applying Stewart’s Theorem, where EF = x, we get 2x(x − 2) + 122 x = 2x2 + x2 (x − 2). We
Sid Stewart’s Theorem 41
simplify to get x3 − 2x2 − 140x = 0, or x2 − 2x − 140. Finally, using the quadratic formula, and
√
discarding the negative solution, we get x = 1 + 141. Remember, the problem asked for the length
√
of AB, which is equal to the length of EB. Therefore, the length of AB is 8 + 1 + 141, or
√
9 + 141, making our answer 150 .
As seen, Stewart’s Theorem can be used to easily solve many advanced geometry problems.
Example 3
In △ABC, we have AB = 1 and AC = 2. Side BC and the median from A to BC have the
same length. What is BC? (2002 AMC 12B #23)
Feel free to draw your own diagram. However, this problem is quite simple. Let’s refer to the point of
intersection with the median and BC as D. We can apply the formula when AD is a median. Since
BC = AD, we can represent this with the variable x. We get
12 + 22 x2
x2 = −
2 4
√
Simplifying, we get x = 2.
d
More Stewart’s Theorem Problems:
Si
More Stewart’s Theorem Problems
https://mathdash.com/maps/map/stewarts?tags=Geometry
Math645 Modular Arithmetic I 42
Modular Arithmetic I
by Math645
https://mathdash.com/maps/map/modular-arithmetic
Operations
We will consider operations with mods, including addition, subtraction, multiplication, division, and
exponentiation. The following 3 theorems, can be proved easily, yet should make intuitive sense so
their proofs are left out.
5
Theorem 1 (Addition, Multiplication, Subtraction, Exponentiation)
4
If a ≡ b mod c and d ≡ e mod c, then:
a + d ≡ b + c (mod c)
h6 ad ≡ bc (mod c)
a − d ≡ b − c (mod c)
In other words, addition, subtraction, multiplication, work as normal if they have the same mod. As
you may have noticed, division was left out, so we will now consider division.
at
Theorem 2 (Division Case 1)
If we have a ≡ b mod c, and n such that n divides a, b, and c, then a
n
≡ b
n
mod c
n
M
You may be wondering why we don’t force that n | a, b as how can we have na if it isn’t directly an
integer. This brings us onto modular division, which is trivial by cross multiplying.
This should make sense immediately by cross multiplying. This fraction can be obtained by guessing
values that are a mod m and seeing if b divides them. For small numbers guessing is the fastest
Math645 Modular Arithmetic I 43
method, yet for bigger numbers, it is best to use a process described in the Linear Diophantine
Equations section of the Diophantine Equations Chapter written by Math645. This chapter has a
section for modular division, which contains practice problems with modular division, a method to
find this fraction, and a proof of why and when this fraction is defined. Please read the Linear
Diophantine Equations Chapter of that book before continuing, as the following chapters do require
the use of modular division and thus linear diophantine equations.
5
Theorem 4 (Wilson’s Theorem)
For a prime, p, (p − 1)! ≡ −1 mod p.
4
Proof: As shown in the Linear Diophantine Equations Chapter, the fraction ab mod m is defined for
all relatively prime b, m. So if we let m = p be a prime, then for b and p to not be relatively prime,
h6
they must share a factor other than 1. Yet the only factor p has other than 1 is p. So they must
share the factor of p to not be relatively prime. So p must divide b and b ≡ 0 mod p. So, for
b ̸≡ 0 mod p, the fraction is defined. We also showed that the fraction has a unique value mod p.
So if we have x then there is a unique value, y mod p such that x ≡ y1 mod p or xy ≡ 1 mod p.
Now let’s list out 1, 2, 3, 4, . . . , p − 1. We will now attempt to group every pair x, y from our
previous definition. But wait, what if x = y, then we can’t group them. Yet we know that if x = y,
at
then x2 ≡ 1 mod p, so x2 − 1 ≡ 0 mod p, so (x − 1)(x + 1) ≡ 0 mod p, so x ≡ 1 mod p, or
x ≡ −1 ≡ (p − 1) mod p. When we group our numbers, we put these numbers on the side. Now we
have the numbers, 1, p−1, (GROUP), (GROUP), (GROUP), . . . . This is just a rearrangement of the
numbers 1, 2, 3, 4, . . . p − 1, so the product of all elements is the same. The product of the elements
in each group is 1, since xy ≡ 1 mod p. So the product of all elements in the rearrangement is
M
1 · (−1) · 1 · 1 · 1 · · · 1 ≡ −1. The product in the original list is (p − 1)!, so (p − 1)! ≡ −1 mod p.
Exponents
We have a theorem to easily calculate numbers taken to large exponents, using a seemingly unrelated
function, Euler’s Totient Function.
Now, we will form the connection between this function and modular arithmetic exponentiation
Math645 Modular Arithmetic I 44
with the following theorem which lets us easily calculate high exponents by reducing the exponent.
Proof: This is equivalent to saying that aϕ(m) ≡ a0 ≡ 1 mod m as then, the exponent is the same as
the exponent mod the totient. To prove this new statement, we will use the set of integers relatively
prime to m and less than m. This set clearly has ϕ(m) elements. Let’s call one member of this set,
x. Clearly, m and x share no divisors. Thus, if we multiply each element of the set by x, we aren’t
adding any common divisors of m, so each member of the new set is relatively prime to m. There
are also still ϕ(m) elements, and they are all relatively prime to m. When taken mod m, no 2 are
5
the same by Divsion Case 2 since if they are the same after, they would have to be the same before.
This means that when taken mod m have all the values relatively prime to m, which is the same as
the inital set. Therefore, the initial set and new set are identical mod m, just rearranged. Thus, the
4
product of all elements is the same mod m. If we call the product of the terms of the original set, y,
then the product of the terms of the new set is y · xϕ(m) . Setting them congruent, and using Division
Case 2, to remove the y (since its relatively prime to m) and we get the desired result.
h6
Now we know how to reduce exponents, but calculating the totient by checking every value less
than m to see which ones are relatively prime, can still take a while. So, the following theorem
provides an easy way to calculate the totient. The proof requires combinatorics and is thus left out
until a later part of the book.
at
Theorem 6
If n can be expressed as pa11 · pa22 · pa33 · · · paxx , then ϕ(n) = n · p1 −1
p1
· p2 −1
p2
· p3 −1
p3
· · · pxp−1
x
M
Example 1
How many different remainders can result when the 100th power of an integer is divided by
125?
Solution: We note that ϕ125 = 100, thus for a relatively prime (to the modulo 125) x, x100 ≡ 1
mod 125. Thus 1 is a possible remainder and occurs for all relatively prime numbers. But, what if
its not relatively prime. If a number isn’t relatively prime to 125, it shares a factor with 125, other
than 1. These factors must be 5, 25, or 125. So it must have a factor of 5 (Since all of 5, 25, 125
have factors of 5, so no matter which factor it shares, 5 is always shared). Anything with a factor of
5 when taken to the 100th power must have a factor of 5100 . It’s clear that every multiple of 5100
is a multiple of 53 = 125. So when it’s not relatively prime, we will always have a multiple of 125,
which must be 0 mod 125. So, in total our possible resiudes are 1 when it’s not relatively prime, and
0 when it is relatively prime, for a total of 2 possible remainders.
Math645 Modular Arithmetic I 45
Example 2
What are the last two digits of 9738 ?
Since we are working in base 10, the last 2 digits will just be the number mod 100, so we need to
calculate 9738 mod 100. We see that 97 and 100 are relatively prime and decide to use Euler’s Totient
Theorem, so 9738 ≡ 9738 mod 40 mod 100. 38 is already as simplified as it can get mod 40, so what
should we do next? We might have noticed that 38 is really close to 40, so if we subtract 40 we
would get a negative number with a really small absolute value. We want really small absolute values
since it would be easier to compute, compared to taking something to the 38th power. And negative
exponents are just fractions which we know how to deal with. So, 9738 ≡ 97−2 ≡ 9712 . Calculating 972
is still hard, so can we simplify it. Note that 97 ≡ −3 mod 100, so 972 ≡ (−3)2 ≡ 9. So 9712 ≡ 19 .
5
This is a lot easier to work with. We want x ≡ 19 mod 100. We cross-multiply to 9x ≡ 1 mod 100
to the Diophantine: 9x = 100y + 1, or 9x − 100y = 1. We solve with the Euclidean Algorithm:
(9, 100) = (9, 9·11+1) = (9, 1) = 1, or in reverse: 1 = 9−8·1 = 9−8·(100−9·11) = 9·89−8·100,
4
so x ≡ 89 mod 100.
CRT
h6
Just like there are system of equations, there are also systems of modular equations that can be
solved with CRT or the Chinese Remainder Theorem. Once again, the theorem should intuitive so
the proof is left out.
at
Theorem 7 (CRT: Chinese Remainder Theorem)
For the modular system of equations:
x ≡ y0 mod z0
M
x ≡ y1 mod z1
x ≡ y2 mod z2
x ≡ y3 mod z3
x ≡ y4 mod z4
..
.
x ≡ yn mod zn
If there are no contradictions, there exists a single solution for x in mod lcm(z1 , z2 , z3 , z4 , . . . , zn )
An example of a contradiction is saying that n ≡ 1 mod 4, which means that n must be odd, but
then saying n ≡ 4 mod 6, which means that n must be even.
Math645 Modular Arithmetic I 46
Example 3
For a positive integer p, define the positive integer n to be p-safe if n differs in absolute
value by more than 2 from all multiples of p. For example, the set of 10-safe numbers is
{3, 4, 5, 6, 7, 13, 14, 15, 16, 17, 23, . . .}. Find the number of positive integers less than or equal
to 10,000 which are simultaneously 7-safe, 11-safe, and 13-safe. (Source: 2012 AIME II Problem
12)
Solution: Note that this is basically saying that n ≡ 3, 4 mod 7 and n ≡ 3, 4, 5, 6, 7, 8 mod 11
and n ≡ 3, 4, 5, 6, 7, 8, 9, 10 mod 13. Note that for each value of mod 7, mod 11, and mod 13, we
pick we will have a unique system of 3 modular equations. Well are there any contradictions? We
see that since 7, 11, 13 are all relatively prime, there can’t be any contradictions, as they share no
factors, so no factors must be divisible and can’t be divisible at the same time. Thus since there are
5
no contradictions, for each value of mod 7, mod 11, and mod 13, we will have a unique solution mod
lcm(7, 11, 13) = 1001. There are 2 ways to pick for mod 7, 6 ways for mod 11, and 8 ways for mod
4
13, so we can do this in 2 · 6 · 8 = 96 ways. Since we have mod 1001, this will always produce 10
values less than or equal to 10,010. So we have a total of 96 · 10 = 960 solutions. However, we want
less than or equal to 10000 not 10010, so we have to subtract off any values that are greater than
h6
10000 and less than 10010 and are 7-safe, 11-safe, and 13-safe. Note that 10010 is divisible by 7,
11, 13. So 10009 ≡ −1 ≡ 6 mod 7, fail. 10008 ≡ −2 ≡ 5 mod 7, fail. 10007 ≡ −3 ≡ 4 mod 7.
It’s 11 − 3 ≡ 8 mod 11 and 13 − 3 ≡ 10 mod 13, pass. 10006 ≡ −4 ≡ 3 mod 7. It’s 11 − 4 ≡ 7
mod 11 and 13 − 4 ≡ 9 mod 13, pass. 10005 ≡ −5 ≡ 2 mod 7, fail. Similarily, 1004, 1003, 1002,
1001 all fail mod 7, so they aren’t 7-safe and thus fail. In total we have to subtract off 2 solutions
to get 960 − 2 = 958 .
at
If there aren’t contradictions, we know there are solutions by CRT but how do we actually find
them? To do this, we must convert them from modular equations to algebraic equations. For
example, we turn x ≡ 3 mod 5 to x = 5y + 3. Then, we can set the algebraic equations equal to
each other. Once setting them equal, we can take everything modulo the lower value to eliminate
a variable to get a 1 variable modular equation, which we can solve just like a regular equation by
M
isolating the variable and dividing. Once we get a modular solution we can convert back into an
algebraic equation for our variable, and substitute into our initial algebraic equation to get a new
algebraic equation and convert that into a modular equation for our answer.
This may sound confusing so let’s try this with a small example right now.
Example 4
Solve for x if x ≡ 4 mod 7, and x ≡ 3 mod 5.
mod 5. To solve this modular division problem we turn it into a Linear Diophantine Equation so
2a + 5m = −1. We solve for 1 and then negate: 2a + 5m = 1. We run the Euclidean Algorithm to
(2, 5) = (2, 2 · 2 + 1) = (2, 1) = 1. So 1 = 2 − 1 · 1 = 2 − 1 · (5 − 2 ∗ 2) = 2 · 3 − 5 · 1. So a ≡ 3
mod 5 gives us 1 so a ≡ −3 ≡ 2 mod 5 gives us −1. Although we got a solution for a mod 5, it
is still hard to relate the equations of different forms, so we convert our value of a to equation form.
a ≡ 2 mod 5 is a = 5c + 2. Plugging into x = 7a + 4, we obtain x = 7(5c + 2) + 4 = 35c + 18.
Thus, x ≡ 18 mod 35.
5
Example 5
Given that x is 3 mod 18, 7 mod 10, and 12 mod 19, find the sum of the two smallest positive
integer values of x
4
Solution: It will be easy to find the two smallest integer values of x when we got a modular solution
for x. Recall to solve 3 equations, we solve any 2 of them and convert it into 1 modular equation, and
h6
then we only have 2 modular equations in total to solve. We pick the first 2 equations to solve first,
so x = 18y + 3 = 10z + 7. Taking everything mod 10, we have 8y + 3 ≡ 7 mod 10, subtracting 3
with the subtraction operation we have 8y ≡ 4 mod 10. Dividing by 2 with Division Case 1 we have
4y ≡ 2 mod 5. Dividing by 2 with Division Case 2 we have 2y ≡ 1 mod 5. We can quickly guess
y = 3 works so y ≡ 3 mod 5. We also did the exact same division in the previous problem. Thus
y = 5n + 3. Plugging into x = 18y + 3, we obtain x = 18(5n + 3) + 3 = 90n + 57. We don’t need to
at
convert into modular form since to solve the next system, we convert back into equation form. Now
we have x = 90n + 57 = 19a + 12. Taking everything mod 19, we have 14n ≡ 12 mod 19. Using
Division Case 2, we divide by 2 first to get 7n ≡ 6 mod 19. Now we solve this Diophantine Equation.
So, 7n − 19m = 6. We solve for 1 and multiply by 6. (7, 19) = (7, 7 · 2 + 5) = (7, 5) = (5 · 1 + 2, 5) =
M
(2, 5). Wait, we could go on all the way until = 1, but remember the only reason we keep going
down is to get simpler ways to equate something to 1, since we don’t know how to do it with the
bigger numbers until we work backwards from smaller numbers. In the previous problem though, we
already knew how to equate (2, 5) to 1 when we did the division in the previous problem. We recall
1 = 2 · 3 − 5 · 1. Now we can just write numbers in terms of previous numbers of our Euclidean
Algorithm. 1 = 2·3−5·1 = (7−5·1)·3−5·1 = 7·3−5·4 = 7·3−(19−2·7)·4 = 7·11−19·4. Thus
n ≡ 11 mod 19 produces 1 as our result to our Linear Diophantine Equation, so n ≡ 11∗6 ≡ 66 ≡ 9
mod 19 produces 6 which is what we needed. Plugging in n = 19p + 9 into our equation for x, we
have x = 90n + 57 = 90(19p + 9) + 57 = 1710p + 867. Thus the smallest 2 positive values for x
are 867, and 867 + 1710 which have a sum of 867 + 867 + 1710 = 3444 .
Euler’s Totient Theorem can be very useful to reduce exponents, however there is a very restricting
clause that the base has to be relatively prime to the mod. So often times when we have a number
that isn’t relatively prime to the mod, we break up the mod into several parts. There will be parts
that are relatively prime to the mod which are easy to calculate with Euler’s Totient Theorem. There
Math645 Modular Arithmetic I 48
will be parts that aren’t relatively prime to the mod which are easy to calculate in general. These
parts can be combined with CRT. Also if numbers are big and computation heavy with the totient
theorem, CRT can break it into smaller more manageable parts that aren’t computation heavy (even
if they were relatively prime before being broken up).
Example 6
Find the last two digits of 10321032 . (Source: 2009 HMMT Guts Round)
Recall last 2 digits in base 10 is just mod 102 = 100. So we need 10321032 mod 100. We can
simplify the base instantly to get 321032 mod 100. We can’t use Euler’s Totient Theorem since 32
and 100 aren’t relatively prime. They share the factor of 4. So we decide to break 4 out of 100.
So we want 321032 mod 4 and 321032 mod 100 = 25, and then use CRT to get our solution mod
5
4
lcm(4, 25) = 100 which is what we need. We solve starting with the relatively prime part so mod 25.
321032 ≡ 71032 ≡ 71032 mod ϕ(25)=20 ≡ 712 ≡ (72 )6 ≡ 496 ≡ (−1)6 ≡ 1 mod 25. Now the part where
4
they share a factor is a lot simpler. 321032 mod 4. Note that 4 divides 32. Thus 4 divides 321032 ,
and thus this part is just 321032 ≡ 0 mod 4. We have transformed this problem into a CRT problem
where, x ≡ 1 mod 25 and x ≡ 0 mod 4. Solving we have x = 25y + 1 = 4z. Taking mod 4, we
h6
have y + 1 ≡ 0 mod 4. Isolating y, we get y ≡ −1 ≡ 3 mod 4. Plugging in y = 4a + 3 we have
x = 25y + 1 = 25(4a + 3) + 1 = 100a + 76. Thus x ≡ 76 mod 100
Example 7
Let a1 , a2 , . . . , a2018 be a strictly increasing sequence of positive integers such that
at
a1 + a2 + · · · + a2018 = 20182018 .
What is the remainder when a31 + a32 + · · · + a32018 is divided by 6? (Source: 2018 AMC 10B
Problem 16)
M
Solution: We need to find a31 +a32 +· · ·+a32018 mod 6 given the value of a1 +a2 +· · ·+a2018 = 20182018 .
The cubes seem to be really annoying so we maybe try to cube the entire thing we have. Yet that
produces too many unwanted turns. We try some experiments. 13 ≡ 1 mod 6. 23 ≡ 8 ≡ 2 mod 6.
33 ≡ 27 ≡ 3, 43 ≡ 64 ≡ 4, 53 ≡ 125 ≡ 5, 03 ≡ 0. We see that a3 ≡ a mod 6, is always true.
(Can be proved by subtracting a from both sides and algebraic factoring). Thus what we need to
find: a31 + a32 + · · · + a32018 ≡ a1 + a2 + a3 · · · + a2018 ≡ 20182018 mod 6. So now this problem is
20182018 mod 6. We see that 2018 isn’t relatively prime to 6 since they share the factor of 2. So we
consider, 20182018 mod 2, and 20182018 mod 3 and then use CRT to combine into mod 6. We start
with the relatively prime part so 20182018 ≡ 22018 mod ϕ(3)=2 ≡ 20 ≡ 1 mod 3. Next the shared factor
part so 20182018 mod 2. We see that 2 divides 2018 so 2 divides 20182018 so this is just 0 mod 2.
We have x ≡ 1 mod 3, and x ≡ 0 mod 2. Its pretty easy to guess that 4 satisfies both of these so
x ≡ 4 mod 6. We also use CRT for practice so x = 3y + 1 = 2z. Taking everything mod 2 gives
us y+! ≡ 0 mod 2 and y ≡ −1 ≡ 1 mod 2. So y = 2a + 1, and plugging into x = 3y + 1 gives
us x = 3(2a + 1) + 1 = 6a + 4. So x ≡ 4 mod 6.
Math645 Modular Arithmetic I 49
Example 8
xx
If f (x) = xx , find the last two digits of f (17) + f (18) + f (19) + f (20). (Source: 2008
PUMAC)
it up into smaller modulos and use CRT. Well what modulos do we split it up into. We need 2 values
5
that have an lcm of 100, and we want to keep them as small as possible so in general we want their
product to be low as well. Note that lcm × gcd = product or 100 × gcd = product. So if we want
the product to be low, we need the gcd to be low. The minimum possible value of the gcd is 1. So the
4
gcd is 1 (general method to break things up with CRT) and the product is 100. This is only possible
by splitting it into 1, 100 (we still have to calculate mod 100 so this doesn’t help) or 4, 25. We
decide to split into 4, 25. Taking mod 4, we have 1717 ≡ 117 ≡ 1 mod 4. Taking mod 25, we have
h6
1717 ≡ 1717 mod ϕ(25)=20 ≡ 1717 . Hmm that didn’t help. It seems like our only way is computational.
It is much less than calculating this same thing mod 100. PUMAC gives a lot of time, so we bash
this out. 1717 ≡ 17 ∗ 1716 ≡ 17 ∗ ((−8)2 )8 ≡ 17 ∗ (142 )4 ≡ 17 ∗ ((−4)2 )2 ≡ 17 ∗ (−9)2 ≡ 17 ∗ 6 ≡ 2
mod 25. So we have something 2 mod 25 and 1 mod 4. CRT gives us x = 25y + 2 = 4z + 1, and
taking mod 4, we have y + 2 ≡ 1 mod 4, so y ≡ −1 ≡ 3 mod 4. Plugging in y = 4a + 3, we get
x = 25(4a + 3) + 2 = 100a + 77. So f (17) ≡ 77 mod 100. We note that in the beginning we tried
at
to calculate things mod 100 which led to bigger numbers in the beginning, but still manageable, until
the end we had huge numbers so we split into smaller modulos. If we started by splitting into smaller
numbers, we would have smaller numbers in the beginning and smaller numbers throughout. So for
next time, we will start by splitting into smaller modulos, even if we may think it is manageable in
bigger modulos, and even if we will always have relatively prime numbers.
M
Now we calculate f (18) mod 100. We have no choice but to split since we don’t have relatively
prime numbers. 18 and 100 share the factor of 2, so we remove all the 2’s from 100 and we split
1818 1818 mod ϕ(25)=20
into 4 and 25. We start mod 25. 1818 . Now the problem becomes 1818
18
≡ 1818
mod 20. These aren’t relatively prime since theyt share 2, so we split 20 into 4 and 5. Starting with
mod 5, 1818 ≡ 318 mod ϕ(5)=4 . Note that 2 divides 18, so 218 divides 1818 , so 22 divides 218 so 22
18 18
divides 1818 , so 1818 is 0 mod 4. So 318 mod 4 ≡ 30 ≡ 1 mod 5. Now we calculate mod 4, so 1818
18 18
by the same logic as earlier is just 0 mod 4, since many powers of 2 divide it. We have a number
0 mod 4 and 1 mod 5 which we can do CRT on to get 16 mod 20. So 1818 ≡ 16 mod 20. So
18
Now we calculate f (19) mod 100. We don’t have to split it but from our lesson learned while
calculating f (17) it is best to split it, and to make the gcd 1, we split into 4 and 25. We start by
Math645 Modular Arithmetic I 50
1919 1919
calculating mod 25: 1919 . So now we calculate 1919 mod 20. Aha, this is
mod ϕ(25)=20 19
≡ 1919
1919 mod ϕ(25)=20
just 1919 ≡ (−1)19 ≡ (−1)odd ≡ −1 mod 20. So plugging into 1919 mod 25, we
19 19
obtain 19 mod 25. This is just 19 ≡ a mod 25. So we solve for a in the Diophantine Equation,
−1 1
Now we calculate f (20) mod 100. We realize we can’t split into parts that are relatively prime and
parts that aren’t since every prime that divides 100 divides 20. So we already have all the parts that
aren’t relatively prime. We see that 4 divides 20 so it divides 20 to any power (Even to the power
5
2020
of 2020 ). We see that 25 divides 202 so it divides 202 to any power (Even to the power of 20 2 ,
20
which is an integer), so 100 divides f (20) so there is no remainder when divided and f (20) ≡ 0 mod
100. Now we add them all up to get 77 + 76 + 79 + 0 ≡ 232 ≡ 32 mod 100.
4
General Modular Arithmetic Practice Problems
h6
Example 9
Calculate the remainder when 97! is divided by 101.
at
Solution: By Wilson’s theorem, we know 100! ≡ −1 mod 101. Dividing by 100 · 99 · 98, we obtain
−1
97! ≡ 100·99·98 −1
≡ −1·(−2)·(−3) ≡ 16 mod 101. Thus we need to find 16 mod 101, or just the solution for
x in to 6x − 101y = 1. We continue, (6, 101) = (6, 6 · 16 + 5) = (6, 5) = (5 · 1 + 1, 5) = (1, 5) = 1.
Reverse, 1 = 5 − 4 · 1 = 5 − 4 · (6 − 5) = 5 · 5 − 4 · 6 = 5 · (101 − 6 · 16) − 4 · 6 = 5 · 101 − 84 · 6,
so −84 ≡ 17 mod 101.
M
Example 10
Let x0 , x1 , x2 , . . . be a sequence of numbers, where each xk is either 0 or 1. For each positive
integer n, define Sn = n−1 k=0 xk 2 Suppose 7Sn ≡ 1 (mod 2 ) for all n ≥ 1. What is the value
k n
P
of the sum x2019 + 2x2020 + 4x2021 + 8x2022 ? (Source: 2022 AMC 10B Problem 25)
2023
7. Now it should also be clear that the quotient is just 2 7 −2 , so we run the Euclidean Algorithm,
2023
(7, 22023 ) = (7, 7·( 2 7 −2 )+2) = (7, 2) = (3·2+1, 2) = (1, 2). So, 1 = 2−1·1 = 2−1·(7−3·2) =
2023 2023 2023
2 · 4 − 7 = (22023 − 7 · 2 7 −2 ) · 4 − 7 = 22023 · 4 − 7 · ( 2 7·4−1 ). Thus y ≡ −( 2 7·4−1 ) mod 22023 .
We also want to bound y or S2023 . The smallest possible value is 0, if all the xk before it are 0, and
the largest possible value, if all the xk before it are 1 is 1 + 2 + 4 + 8 + 16 · · · + 22022 < 22023 by
sum formulas. Thus, since we have a solution mod 22023 , our answer is simply the smallest possible
positive value of that solution mod 22023 , by basic bounding since any values less are less than 0, the
minimum, and any values greater are more than 22023 , the maximum. Our value of y we got was
2023 2023
−( 2 7·4−1 ), which is negative, so we add 22023 , to hopefully make it positive, and we get 2 7·3+1 this
is positive, more than the minimum, and less than the maximum, and adding or subtracting 22023 will
2023
make it more than the max or less than the min so this value is S2023 = 2 7·3+1 . We proceed with
calculating S2019 . We have that 7S2019 ≡ 1 mod 22019 . Which by the same logic as earlier, converts
to 7b − 22019 c = 1 where b = S2019 . First we calculate the remainder and quotient with Euler’s
5
Totient Theorem Extended, and we get 22019 ≡ 23 ≡ 8 ≡ 1 mod 7. So the remainder is 1, and the
2019 2019
quotient is 2 7 −1 . With Euclidean Algorithm, we obtain (7, 22019 ) = (7, 7 · 2 7 −1 + 1) = (7, 1) = 1.
2019 2019
Running it in reverse gives us 1 = 7−6·1 = 7−6·(22019 −7·( 2 7 −1 )) = 7·(1+6· 2 7 −1 )−6·22019 .
4
2019 2019
Thus S2019 ≡ 1 + 6 · 2 7 −1 ≡ 6·2 7 +1 mod 22019 . By the same bounding argument as last time,
2023 2019 ·6−1 2019 4 2019 ·6 2019
this is the solution. Now S2023 − S2019 = 2 ·3+1−2 7
= 2 ·2 ·3−27
= 2 7 ·42 = 22019 · 6.
Dividing by 22019 from our expression earlier gives us a final answer of 6
h6
Try it Yourself!
https://mathdash.com/maps/map/modular-arithmetic
https://mathdash.com/maps/map/euler’s-totient-theorem
at
https://mathdash.com/contest/Modular-Arithmetic-I-All-in-One
-Problem/
M
MathDash MATHCOUNTS 52
MATHCOUNTS
by MathDash Community
https://mathdash.com/contests?tag=MATHCOUNTS
h
as
hD
at
M
MathDash AMC 10 53
AMC 10
by MathDash Community
https://mathdash.com/contests?tag=AMC+10
h
AMC 10 Full-Length Mocks
as
https://mathdash.com/contests?tag=AMC+10
hD
at
M
Aaron Cyclic Polynomials 54
Cyclic Polynomials
by Aaron
Introduction
Thanks to John Z. for helping with LATEX and clarifying some confusing parts!
Definition 1
A symmetric polynomial is a polynomial that remains unchanged under the exchange of any
pair of variables. In other words, swapping any two variables in the polynomial does not affect
its form. For example, x+y +z and x2 (y +z)+y 2 (z +x)+z 2 (x+y) are symmetric polynomials
since switching any two pairs of variables leaves the polynomial unchanged.
Definition 2
n
ro
A cyclic polynomial is a polynomial that remains unchanged under cyclic permutations of its
variables, which means that if you rearrange the variables in a circular fashion, the polynomial
expression stays the same; essentially, it exhibits rotational symmetry among its variables. For
example, x2 y + y 2 z + z 2 x is cyclic, but is not symmetric. (Do you see why?)
Aa
All symmetric polynomials are cyclic; however, not all cyclic polynomials are symmetric.
Theorem 1
The factorization of a cyclic polynomial must also be cyclic. In addition, the addition, subtrac-
tion, multiplication, and division of two cyclic polynomials always result in a cyclic polynomial.
Theorem 2
If the polynomial equation P (x) = an xn + an−1 xn−1 + an−2 xn−2 + · · · + a1 x + a0 = 0 has root
x = r, then (x − r) is a factor of P (x).
Theorem 3
For a two-variable polynomial equation P (x, y) = 0, if x = −y is a solution, then (x + y) is a
factor of P (x, y).
Aaron Cyclic Polynomials 55
Theorem 4
For a three-variable polynomial equation P (x, y, z) = 0, if x = −y − z is a solution for x, then
(x + y + z) is a factor of P (x, y, z).
Sometimes, cyclic polynomials can be lengthy and difficult to write out completely. Because of this,
we have a shorter notation for cyclic polynomials, for example:
X
P (x, y, z) = x(y − z) + y(z − x) + z(x − y) = x(y − z)
cyc
Factoring
Let’s try some examples. Be sure to attempt the questions on your own before looking at the solution.
Example 1
Factor (x + y + z)5 − x5 − y 5 − z 5 .
n
ro
Solution. Since the expression is cyclic, we can start by identifying some simple factors.
We know that (x+y +z)5 −x5 −y 5 −z 5 is a 5th -degree polynomial so what’s left is a second-degree
Aa
polynomial. In addition, by Theorem 1, we know that the rest of the stuff must be cyclic, and the
only factor to achieve those two things is in the form of a(x2 + y 2 + z 2 ) + b(xy + yz + zx). Therefore,
the expression (x + y + z)5 − x5 − y 5 − z 5 can be factored as:
Example 2
Factor (a + b + c)3 − (b + c − a)3 − (a + c − b)3 − (a + b − c)3 .
If we set a = 0, the value becomes (b + c)3 − (b + c)3 − (c − b)3 − (b − c)3 = 0. This indicates
that the expression has a factor of a, which implies it also has a factor of abc.
Aaron Cyclic Polynomials 56
Since it is a cubic expression and we already have a degree of 3 in abc, the complete factorization
must take the form kabc. When we set a = b = c = 1, we find that k = 24. Therefore, the final
result is 24abc .
Example 3
Factor (x + y)5 − x5 − y 5 .
The remaining part must be quadratic. Therefore, we can express it as xy(x+y)(ax2 +ay 2 +bxy).
n
2. If x = 2 and y = −1, we find −30 = −2(5a − 2b).
ro
Solving these equations leads to a = 5 and b = 5.
Since it is a 3rd power expression, we must have: k(b + c − a)(a + c − b)(a + b − c). By checking
the coefficient of a3 , k = −1. Hence the answer is: −(b + c − a)(a + c − b)(a + b − c) .
Complex Numbers
by Sid
https://mathdash.com/maps/aime-complex-numbers-and-polynomials
Theorem 2
√ √
|z| = a2 + b2 = zz
Theorem 4
Let F (x) = a0 + a1 x + a2 x2 + · · · + an xn , where all an are real numbers. If z = a + bi is a
root of F (x), then z = a − bi is also a root.
Example 1
Let z be a complex number, given that z 2 = 12 + 16i. Find z, given that the real part of z is
positive.
Solution: Let z = a + bi. We know that a2 − b2 + 2abi = 12 + 16i. Since a2 − b2 must be real,
and 2abi must be imaginary, we can create two separate two-variable equations:
2abi = 16i
a2 − b2 = 12
For the first equation, we can divide by 2i from both sides to get ab = 8. From here, we can solve
the two variable equation, but it is easy enough to see that a = 4, and b = 2, or a = −4 and b = −2
satisfy the equations. We know that the real part must be positive by the problem conditions, so our
answer is z = 4 + 2i .
d
Si
Example 2
Let N be the number of complex numbers z such that |z| = 1, and z 720 − z 120 is a real number.
Find the remainder when N is divided by 1000. (2018 AIME I #6)
Solution: Since the result is a real number, you know that the z 720 − z 120 = z 720 −z 120 . Additionally,
we know that the magnitude of z is 1, so zz = 12 = 1, and z = z1 . Now, we substitute it back in,
getting
1 1
z 720 − z 120 = 720 − 120
z z
Multiply by z 720
so all the exponents are positive, and we realize that we have a single variable
polynomial with degree 1440, meaning there should be 1 440 solutions.
Definition 4 (Argument)
The argument (θ) of a complex number is represented as the angle the complex number makes
with the positive real axis (x-axis) and the line from the origin to the complex number.
Sid Complex Numbers 59
Theorem 5 (Argument)
b
tan θ = a
Theorem 6
z = a + bi = r(cos θ + i sin θ) = r cis θ, where cis θ is just short form for cos θ + i sin θ.
√
Solution: First, we calculate the magnitude to be 36 = 6. Now, we convert to polar form. We see
√
that that b/a = 3, meaning that the angle must be π3 radians. This means that z = 6eiπ/3 . Now,
taking this to the 16th power, we get 616 ei16π/3 . Converting this to cis θ, we get
616 (cos 16π/3 + i sin 16π/3)
√
Now, we evaluate cos 16π/3 = −0.5, and sin 16π/3 = − 2
3
. Now, converting back to a + bi, we get
√
16 616 616 3
z =− −
2 2
Sid Complex Numbers 60
Example 4
Given that z1 + z2 + z3 = 0, and |z1 | = |z2 | = |z3 | = 1, evaluate z1 z2 + z2 z3 + z3 z1 .
Solution: We know that the magnitude is equal to 1, meaning they lie on the unit circle. WLOG,
fix z1 to the top. That means that z2 and z3 must have imaginary parts of −0.5 so the real parts
cancel out too. Since sin 330 = sin 210 = −0.5, it means that they are both 30◦ from the real
axis, meaning they are equally spaced on the unit circle. This means that z1 , z2 , and z3 can be the
solutions to the equation ω 3 = 1, with z = 1, z2 = ω, and z3 = ω 2 . Now, we get our product in
terms of ω to be ω + ω 2 + ω 3 . This is just z1 + z2 + z3 , meaning our answer is 0 .
Example 5
Given that z is a complex number such that z + 1
z
= 2 cos 3◦ , find the least integer that is
greater than z 2000 + z2000
1
. (2000 AIME II #9)
Solution: We express z to be on the unit circle in the complex plane. Then, z = 1 ∗ eiθ = eiθ . Note
that z1 = z −1 = e−iθ . Expressing these in cis θ form, and considering that z + z1 = 2 cos 3 we get
d
cos θ + i sin θ + cos θ − i sin θ = 2 cos 3 cos θ = cos 3θ = 3
Now, we evaluate z 2000 + z −2000 using De Moivre’s, noting that the sin terms will cancel out, getting
2 cos 6000 = 2 cos 240 = −1, meaning that our answer is 000 .
Si
Practice Problems: (Solutions at end of chapter)
Example 6
The equation z 6 + z 3 + 1 = 0 has complex roots with argument θ between 90◦ and 180◦ in the
complex plane. Determine the degree measure of θ. (1984 AIME #8)
Example 7
There are 24 different complex numbers z such that z 24 = 1. For how many of these is z 6 a
real number? (2017 AMC 12A #17)
Example 8
Let z = a + bi be the complex number with |z| = 5 and b > 0 such that the distance between
(1 + 2i)z 3 and z 5 is maximized, and let z 4 = c + di. Find c + d. (2013 AIME II #6)
Sid Complex Numbers 61
Example 9
Let S be the set of all polynomials of the form z 3 + az 2 + bz + c, where a, b, and c are integers.
Find the number of polynomials in S such that each of its roots z satisfies either |z| = 20 or
|z| = 13. (2013 AIME II #12)
Solutions:
y2 + y + 1 = 0
√
Using the quadratic equation, we get the solution to be y = − 21 ± 23i . The argument is 120◦
and 240◦ respectively, and they both have a magnitude of 1. This means that we can write it
d
as z 3 = cos 240◦ + i sin 240◦ and z 3 = cos 120◦ + i sin 120◦ . Taking both to the power 13 , we get
cos 40◦ +i sin 40◦ , and cos 80◦ +i sin 80◦ . Now, we know that the argument repeats in intervals of 120◦
for both, since 360/3 = 120, so the possible roots would be 40◦ , 160◦ , 280◦ , 80◦ , 200◦ , and 320◦ .
Si
The only one between 90◦ and 180◦ is 160 .
#7: Let a = z 6 . Since z 24 = 1, a4 = 1, and since a must be real, a = ±1. This means that
z 6 = 1, or z 6 = −1. By Fundamental Theory of Algebra, we know there are exactly 6 complex
solutions to both these cases, meaning the answer is 12 .
Case 1: All the roots are real. Since the magnitude is 20 or 13, the possible
values are 20, −20,
13, −13. We use stars and bars to evaluate that the amount of ways is 3 = 20.
6
Case 2: Two of the roots are imaginary and one is real (Note that because of Theorem 4, the
two imaginary roots must be complex conjugates). There are 4 ways to choose the real roots. For
the imaginary roots, let one of the imaginary roots be m + ni, and the other be m − ni, and denote
Sid Complex Numbers 62
√
the real number to be r. We know that m2 + n2 = 20 or 13. Applying Vietta’s equations, we get
a = −(2m + r)
b = m2 + n2 + 2mr
c = −(m2 + n2 )
√
Since r is an integer, we can ignore that. Additionally, since m2 + n2 = 20 or 13, we know that
m2 + n2 is an integer too. Now, we see that the only way that will make a, b, and c all integers
is if 2m is an integer. Since |m| has to be less than 20 or 13 (depending on what the magnitude
is) (since otherwise n ≤ 0, which doesn’t work), that means that if the magnitude is 13, then the
possible values for m will be 0, ± 21 , ± 22 , ± 32 , · · · ± 25
2
, meaning there are 51 ways. Similarily, if the
magnitude is 20, there will 79 ways. This means in total (for this case), there are 130 ∗ 4 = 520.
Adding up the two cases, we get 520 + 20 = 540 .
d
Si
MathDash Note about and Notation 63
X Y
P
Mathematicians just love sigma notation ( ) for two reasons. First, it provides a convenient way to express a long
or even infinite series. But even more important, it looks really cool and scary, which frightens nonmathematicians
into revering mathematicians and paying them more money.
— Caculus II for Dummies, p. 51
X Y
-notation and -notation are used later in this book. In case you don’t know, here’s what
they mean.
h
m
f (k) means to take the sum where the terms are given by plugging in different ks into f (k),
X
k=n
starting from k = n to k = m, with an increment of 1. Note that the part that follows the
as
summation does not have to be a function; it can simply be an expression involving k. k can
be whatever letter you want, it just has to match the letter in the expression later. It’s called
a dummy variable.
If the upper bound is infinity we use ∞. Here’s an example of such notation. An upper bound
of infinity basically means the limit of the sum as n gets arbitrarily large. The following means that
a
ar0 + ar1 + ar2 + · · · = 1−r .
at
∞
a
arn = , for |r| < 1
X
n=0 1−r
k=3
n
X n(n + 1)
k = 1 + 2 + 3 + ··· + n =
k=1 2
n
Y
n! = k
k=1
Exercise. Write the formula in notation: The sum of the first n perfect cubes is equal to the
X
Linearity of Expectation
by MathDash Team
https://mathdash.com/maps/map/linearity-of-expectation
h
as
Example 1
A six-sided die is rolled, having sides 1, 2, 3, 4, 5, 6. What is the expected value of the result
of the roll?
hD
Solution: We can use the definition of expected value — let A be the random variable for the
result of the dice roll. We know that the expected value of A is
E[A] = P (A = 1) · 1 + P (A = 2) · 2 + P (A = 3) · 3 + P (A = 4) · 4 + P (A = 5) · 5 + P (A = 6) · 6
P (A = i) = 1
6
for each i = 1, 2, 3, 4, 5, 6, so this simplifies to simply A = 61 (1 + 2 + 3 + 4 + 5 + 6) =
21
6
= 3.5.
That was easy enough. Now let’s look at a very basic example of Linearity of Expectation
at
Example 2
If a random number a has an expected value of 3, and a random number b has an expected
value of 4, what is the expected value of a + b?
M
Turns out that you can easily guess than the answer would be 3 + 4 = 7 . This is precisely what
Linearity of Expectation says — for any two random variables A, B, we have that E[A + B] =
E[A] + E[B]. More generally,
In other words, the expected value of the sum is the sum of the expected values.
MathDash Linearity of Expectation 65
Easy enough — why is this even a theorem you may ask — it seems very obvious! Of course the
expected value of a sum should be the sum of the expected values. Well, let’s take a look at the
next problem
Example 3
(Classic) n students take a test. Afterwards, the teacher decides to randomly scramble the tests
and give each student one of the tests back. What is the expected number of students who get
their own test back?
What an impossible looking question — trying to do this naively would mean we would need to
h
count the number of ways to give the tests back such that one student got their own test back, two
students, three students, etc. Each of those cases are really tricky problems in their own right.
as
Solution: Let’s use the power of indicator variables to help us solve this. Let Ai be a random
variable defined as follows:
1,
if the i-th student receives their own test
Ai =
0,
otherwise
hD
First, I claim that the number of students who get their own test back is A1 + A2 + · · · + An . Why?
This is because Ai will be 1 for each student that gets their own test back, and 0 otherwise — so
the sum will count the number of students who get their own test back.
E[A1 + A2 + · · · + An ]
What is E[Ai ] (for an arbitrary i)? Well, the definition of expected value tells us this is 0 · P (Ai =
0) + 1 · P (Ai = 1) — so this is just P (Ai = 1), or the probability that the i—th student receives
their own test. Well — we know what that is — the probability that the i-th student receives their
M
1
own test is .
n
So, E[Ai ] = n1 , and
1 1 1
E[A1 ] + E[A2 ] + · · · + E[An ] =
+ + ··· + = 1
n n n
In other words, the expected number of students who get their own test back is 1.
Linearity of Expectation is one of the most beautiful and satisfying tricks to use in contest math!
Hopefully you were impressed by the ease at which Linearity of Expectation helped solve that otherwise
quite impossible question.
The perhaps surprising part of Linearity of Expectation is that it holds even when the random
variables depend on each other ! In this case, A1 depends on A2 — for example, whether or not
MathDash Linearity of Expectation 66
person 1 receives their own test back definitely impacts the probability that person 2 receives their
own test back. However, we can still use Linearity of Expectation here because it holds in general,
not only for independent events.
(As a sidenote, for independent random variables A1 , A2 , E[A1 A2 ] = E[A1 ]E[A2 ] — but this is
not true if the random variables depend on each other).
Example 4
Ten people of different heights stand in a line in a random order. A person ’looks tall’ if they
are taller than both the person to the left and to the right of them (or, if they are on the edge,
h
taller than the one person next to them). What is the expected number of people who look
tall?
as
Solution: We will use the trick of indicator variables yet again! Let Ai be the random variable
defined as such:
1, if the i-th person in line looks tall
Ai =
0, otherwise
hD
Note that the number of people who look tall is A1 + A2 + · · · + A10 . So we just need to find the
expected value of this sum, or
E[A1 + A2 + · · · + A10 ]
Which by Linearity of Expectation is equal to
Now, how do we find this sum? As in the previous problem, E[Ai ] is equal to 0·P (Ai = 0)+1·P (Ai =
at
1) — so this is just P (Ai = 1), or the probability that the i-th person in line looks tall.
Let’s try to figure out what P (A1 = 1) is — this is the probability that the first person in line
’looks tall’. Well — each possible random ordering of people can be paired up with another random
ordering with the position of the first two people swapped. In exactly one of the two of these, the first
M
person in line ’looks tall’ and in the other one, they don’t! So, in exactly 21 of the random orderings,
the first person in line looks tall. Thus, P (A1 = 1) = 21 . Similarly, P (A10 = 1) = 12 .
P (A2 = 1) is a little different — this is the probability that the second person in line ’looks tall’.
We can use a similar idea though — we group all of the orderings into groups of 6 — the group is
determined by the ordering of the participants who are not in the 1, 2, or 3 slot. Each group of six is
the same ordering except with the order of 1, 2, 3 changed to be one of the 6 possible orderings. In
1
exactly two of these orderings, the second person in line ’looks tall’ — so across all permutations, of
3
them have the second person in line ’look tall’. Thus, P (A2 = 1) = 31 , and similarly, P (Ai = 1) = 31
for i = 2, 3, · · · , 9
MathDash Linearity of Expectation 67
So, the expected value of the number of people who look tall is E[A1 + A2 + · · · + A10 ] which is
1 1 1 1 1
E[A1 ] + E[A2 ] + · · · + E[A10 ] = + + + ··· + +
2 3 3 3 2
8
= 1+
3
11
= .
3
You can imagine trying to do this question without linearity of expectation — you’d have to count
the number of permutations of 10 people for which there are 0 people who look tall, 1 person who
looks tall, 2 people who look tall, 3 people who look tall, etc. After performing an incredibly large
number of calculations, you would arrive at a final answer of 11 as well. Linearity of Expectation
h
3
saves us a lot of time!
as
Try some Linearity of Expectation Problems
https://mathdash.com/maps/map/linearity-of-expectation
hD
at
M
Sepehr Golsefidy and Aditya Bisain Recursion 68
Recursion
by Sepehr Golsefidy and Aditya Bisain
https://mathdash.com/maps/map/recursion
in
sa
Introduction
Bi
States and Recursion are both fundamental to AMC 10/12 or AIME Problems. They can be a helpful
tool to get rid of large amounts of casework, which can often lead to silly mistakes. But how exactly
a
do these tools work?
ity
Recursion The idea of recursion is that we have a sequence, say, an , where n represents the nth
Ad
term, and we want to be able to express an in terms of the previous terms of this sequence, such
as an−1 , an−2 , etc. A very famous example of a this is the Fibonacci sequence, where the nth term
of this sequence is denoted by Fn , and Fn is defined by the sum of the previous two terms. So,
d
Fn = Fn−1 + Fn−2 . We call this a recurrence relation.
an
Example 1
Determine the maximum number of regions formed by n lines in the plane.
lse
We can guess by checking small cases that the pattern adds 1, 2, 3, and so on, so the final answer
Go
should be (n)(n+1)
2
+ 1, but how are we going to prove it?
Solution
hr
Let’s play around with this. If we have 0 lines, we have 1 region. With 1 line, this splits old region
pe
up into 2 regions. When we add another line, first, notice that we never want lines to be parallel
because we want to maximize the number of regions formed. If we draw a 2nd line that is parallel to
Se
the first one, we only create 3 regions. If we have it intersect the first line, then it creates 4 regions.
At this point you might’ve guessed that the answer is 2n , where n represents the number of lines
we draw. But once we add a third line, we see that the maximum regions we can form is 7. . .
The idea is that when we add the third line, it can intersect at most the two other lines. The 2
intersections splits up the third line into three separate chunks, and each of these chunks splits up
Sepehr Golsefidy and Aditya Bisain Recursion 69
an existing region into 2 regions. So in general, if we have n lines, and we add one more line, this
new line will have at most n intersection points, splitting the line up into n + 1 segments, forming
n + 1 new regions in addition to the previously existing regions.
So, our recurrence relation is an+1 = an + (n + 1), where an represents the maximum number if
regions with n lines.
in
Now lets try to get a closed form for an . We have that an = n + an−1 . By our recurrence
sa
relation, we can plug in an−1 = n − 1 + an−2 , which yields an = n + (n + 1) + an−2 . Plugging in
an−2 = n − 2 + an−3 , which gives an = n + (n − 1) + (n − 2) + an−3 . At this point, we start to see the
Bi
triangular number pattern. From here, we can see that an = n + (n − 1) + (n − 2) + · · · + 1 + a0 =
n(n+1)
2
+ 1, and we are done. (Note: the +1 at the end comes from the fact that a0 = 1, which
represents that there is 1 region when we draw 0 lines).
a
ity
The process of recursion, as seen in the previous solution, has two major steps: forming a relation
and solving it. Let’s try another example of this.
Example 2
Ad
How many sequences of length n are there consisting of digits in the set 0, 1 such that there
d
are no two consecutive 0’s in this sequence?
an
Solution
y
fid
Forming the Recurrence: Note that there are two cases: the sequence ends with a 0 or a 1.
If the length of the sequences with length i are denoted with ai if the sequence ends with 0, and
lse
bi if otherwise. Notice that if this sequence ends in a zero, the previous digit must be 1. As a
result, bi = ai−1 . If the sequence ends in a 1, the previous digit might be either a 1 or a 0. Thus,
ai = bi−1 + ai−1 .
Go
Solving: We try to make the entire thing in terms of one sequence. In this case, it’s simple to
set bi−1 = ai−2 , and so ai = ai−1 + ai−2 . Now, if we’re looking at the possibility for the n digit
sequence, we must find an + bn = an + an−1 = an+1 . Note that since ai is defined as the Fibonacci
hr
Sequence, we get an+1 = Fn+1 , where Fn+1 is the n + 1th term in the sequence. This is our final
answer.
pe
We’ll cover one more example and then go into our next topic.
Se
of the integers 1, 2, . . . , 7.
Solution
in
We will solve this for n integers.
sa
Lemma: If we call the number of permutations possible for i integers ai , the number of permuta-
tions possible for i + 1 integers is ai+1 = 3ai .
Bi
Proof: How many ways are there to place the i + 1 after the i terms? Only before the i − 1, i, and
right at the end. Thus, our result is proven.
a
ity
Before we move to states, I would like to cover a small bit of the general formula of a recursive
sequence.
Characteristic Polynomials
Ad
d
an
Definition 1
If a recurrence equation
y
exists, define the characteristic polynomial of this recurrence be f (x) = xn − c1 xn−1 + c2 xn−2 +
· · · + ck .
lse
Example 4
hr
If a recurrence G is defined with Gn = c1 Gn−1 +c2 Gn−2 +· · ·+ck Gn−k , define the characteristic
polynomial of this recurrence be f (x) = xn − c1 xn−1 + c2 xn−2 + · · · + ck . Then the term Gn
pe
can be written as a1 (r1 n ) + · · · + an (rn n ) if ri ’s are the roots to our characteristic polynomial,
and if the characteristic polynomial has distinct roots.
Se
Solution
Define generating function H(x) such that H(x) = G0 + G1 (x) + . . . + Gi (xi ) + . . .. Here comes the
genius step: consider kj=1 cj H(x)xj−1 . If we observe the xk+i (where i is an integer greater than or
P
equal to −1) term in the expansion, we observe that the sum over this is ck Gi+1 + ck−1 Gi+2 + . . . . +
Sepehr Golsefidy and Aditya Bisain Recursion 71
c1 Gi+k . But amazingly, this simplifies to Gk+i+1 . But this is the coefficient we get if we divide H(x)
x
.
As a direct result, j=1 cj H(x)x H(x)+R(x)
, where R(x) is a polynomial of degree less than or
Pk j−1
= x
equal to k − 1.
Through this, we multiply by x on both sides, subtract by H(x) on both sides, and factor H(x) to
get H(x) = ck xk +ck−1 xR(x)
k−1 +···+c x−1 . But the denominator is just a flip of the characteristic polynomial!
in
1
So the roots of the denominator are r1i for i ranging from 1 to n. Since the roots of the characteristic
sa
polynomial are distinct, we write the partial fraction decomposition of H(x) as above: it can be
written as km=1 1−r nm
. We are using the fact that the degree of R(x) is less than or equal to k − 1
P
mx
Bi
here, and that the denominators divide the other denominator. Now, we use the geometric series
formula and compare with the coefficients of H(x). As a result, Gn = a1 r1 n + a2 r2 n + · · · + ak rk n ,
and we have proved our final result.
a
I implore you to find another result but if the characteristic polynomial has a root with multiplicity
ity
more than 1.
Ad
This may seem complicated, but it gets more simple through simple numerical examples.
d
Example 5
√ √
( 1+25 n
) −( 1−2 5 )n
an
Prove Binet’s formula, which states that Fn = √
5
.
y
Solution
fid
√ √
Fibonacci’s characteristic polynomial is x2 − x − 1 = 0. The roots are 1+2 5 , 1−2 5 . Now, we look for
√ √ √ √
lse
Example 6
hr
(2018 USAJMO P1) For each positive integer n, find the number of n-digit positive integers
that satisfy both of the following conditions:
pe
Solution
Look at the second digit from the left, and call the amount of number of n digit numbers that satisfy
this property an . If it is 0, then the number of n − 2 digit numbers times 9 is the total possibility. If
Sepehr Golsefidy and Aditya Bisain Recursion 72
not, it is n−1 digit numbers times 8. Thus, our recurrence is an = 8an−1 +9an−2 . The characteristic
polynomial is x2 − 8x − 9, so we must find constants a and b such that a(9)n + b(−1)n . Finding the
cases where n = 1 and n = 2, we find that 9a − b = 4, 81a + b = 32. Add the two expressions up,
find a and b, and finish.
in
Try some Recursion Problems (MAPS)
sa
https://mathdash.com/maps/map/recursion
Bi
a
ity
Ad
d
an
y
fid
lse
Go
hr
pe
Se
MathDash Generating Functions 73
Generating Functions
by MathDash Team
https://mathdash.com/maps/map/generating-functions
Generating functions are a powerful tool in combinatorics that allow us to encode sequences of
numbers as coefficients in a power series. By manipulating these power series, we can solve some of
the most difficult combinatorics and algebra problems in competition math!
h
Example 1
There are three baskets on the ground: one has 2 purple eggs, one has 2 green eggs, and one
has 3 white eggs. Eggs of the same color are indistinguishable. In how many ways can I choose
as
4 eggs from the baskets?
Solution
hD
Let’s express the conditions as polynomials. This may seem crazy at first, but bear with me! Since
we can choose either 0, 1, or 2 eggs from the first basket (purple eggs), we can represent this as:
x0 + x1 + x2
x0 + x1 + x2
at
For the white eggs, since we can choose 0, 1, 2, or 3 eggs, we represent this as:
x0 + x1 + x2 + x3
Now let term in the resulting polynomial correspond to choosing one term from each of the original
polynomials! For instance, if we choose x0 from the first factor, x1 from the second, and x2 from
the third, this would correspond to choosing 0 purple eggs, 1 green egg, and 2 white eggs.
So, this 7th -degree monstrosity of a polynomial in fact is the sum of many individual terms each
representing a way to pick eggs from our three baskets!
The problem is asking for the number of ways to choose 4 eggs from the basket. Conveniently,
each term representing one of these ways evaluates to x4 ! So, we only need to find the coefficient of
x4 in the resulting polynomial.
MathDash Generating Functions 74
Furthermore, this wild method of solving this question also tells us that there is 1 way to choose 7
eggs, 3 ways to choose 6 eggs, 6 ways to choose 5 eggs, 8 ways to choose 3 eggs, 6 ways to choose
2 eggs, 3 ways to choose 1 egg, and 1 way to choose 0 eggs! (We can see this by simply looking at
the coefficients of the polynomial).
Example 2
h
Find a general formula for the Fibonacci sequence, satisfying the recurrence f0 = 0, f1 = 1,
and fn = fn−1 + fn−2 for n ≥ 2.
Solution
as
Let’s tackle the Fibonacci sequence using generating functions! Generating functions are not just for
hD
combinatorics; they shine in solving recurrence relations too.
First, let’s define the generating function F (x) for the Fibonacci sequence {fn } as:
F (x) = f0 + f1 x + f2 x2 + f3 x3 + f4 x4 + · · · (1)
= 0 + 1x + 1x2 + 2x3 + 3x4 + 5x5 + · · · (2)
In general, this is how we will define the generating function of any sequence! You might be
at
confused about what x “means” here. It’s just a generic input to a function — the function itself is
what we really care about!
Now, given the recurrence relation fn = fn−1 + fn−2 , we can express this in terms of F (x) as
follows:
M
n=2
n=2
is the original generating function without the first two terms. Also,
∞ ∞ ∞
fn−1 xn = fn xn+1 = x f n xn
X X X
h
1 − x − x2
And voila, we have a nice closed form for the generating function of the Fibonacci sequence!
Now, to find the general formula for fn , we will write F (x) in a form where the coefficients are
as
clearly defined! To do this, we need to express F (x) in a form that allows us to figure out it’s
coefficients. Let’s use partial fraction decomposition.
F (x) = −
(ψ − ϕ) 1 − ψx 1 − ϕx
Recognizing the sum of geometric series:
∞ ∞
!
1
ψ n xn − ϕn xn
X X
F (x) = √
− 5 n=0 n=0
M
Here are some common generating functions — maybe it could be exciting to try proving them
yourself!
h
Theorem 2 (Negative Binomial Theorem)
For any real number α and |x| < 1,
as
∞
!
−α
X α+k−1 k
(1 − x) = x .
k=0 k
hD
Theorem 3 (Generating Function for Combinations)
For fixed k,
∞
xk
!
X n n
x = .
n=0 k (1 − x)k+1
Given the Fibonacci sequence {Fn } where F0 = 0, F1 = 1, and Fn = Fn−1 + Fn−2 for n ≥ 2,
∞
x
F n xn =
X
.
n=0 1 − x − x2
M
h
n
X
Cn x = .
n=0 2x
as
Example 3
Let n be a positive integer. Show that
! ! !
n−1 n−2 n−3
Fn = + + + ···
hD
0 1 2
where Fn denotes the nth Fibonacci number
Solution
! ! !
n−1 n−2 n−3
Well, let an = Fn and let bn = + · · · . If we can show that
at
+ +
0 1 2
a0 + a1 x + a2 x 2 + · · · = b 0 + b 1 x + b 2 x 2 + · · ·
, then we are done since the polynomials being equal (as polynomials) means that each coefficient is
equal!
M
Note that
∞
!
X n−1−i
bn =
i=0 i
So,
∞ ∞ X
∞
!
n−1−i n
bn x n =
X X
x
n=0 n=0 i=0 i
∞ X ∞
!
X n−1−i n
= x
i=0 n=0 i
∞ ∞
!
X
1+i
X n − 1 − i n−1−i
= x x
i=0 n=0 i
MathDash Generating Functions 78
h
https://mathdash.com/maps/map/generating-functions
as
hD
at
M
MathDash Ptolemy’s Theorem 79
Ptolemy’s Theorem
by MathDash Team
https://mathdash.com/maps/map/ptolemy
Figure 3: Ptolemy — AB · CD + AD · BC = AC · BD
D
h
O
as
C
B
hD
Theorem 1 (Ptolemy’s Theorem)
Given four points on a circle in the order A, B, C, D,
AB · CD + AD · BC = AC · BD
at
Proof:
A A A
B B B
M
K K K
D D D
C C C
Source: Wikipedia
Let’s construct a point K on AC such that ∠ABK = ∠DBC. Note that this makes △AKB is
similar to △BDC because of angle-angle similarity (since ∠BAK = ∠BDC).
AB BD
So, = . Cross-multiplying gives us AB · CD = AK · BD. Nice — we’ve been able to
AK DC
re-write one term in the Ptolemy’s Theorem equation. Let’s do it again!
MathDash Ptolemy’s Theorem 80
Since ∠ABK = ∠DBC, adding ∠KBD to both tells us ∠ABD = ∠KBC. Coupling this with
AD KC
the fact that ∠BDA = ∠BCK, we see that △ABD is similar to △KBC. This tells us =
BD BC
or AD · BC = BD · KC.
h
if and only if A, B, C, D lie on a circle
as
Example 1
A regular hexagon ABCDEF is inscribed in a circle. If P is on the minor arc BC, and
P E = 10, P F = 11, find P A + P B + P C + P D.
hD
P
B C
at
A D
M
F
E
Solution: Let’s use Ptolemy on some of the cyclic quadrilaterals in this diagram! If we use
Ptolemy’s on the red quadrilateral P CEA, we get P A · EC + P C · AE = P E · AC. Note though
that △ACE is an equilateral triangle (being the alternate vertices on a regular hexagon)! So,
AC = CE = AE. Dividing by this side length gives us P A + P C = P E.
h
as
hD
at
M
Samuel Other Cyclic Quad Theorems 82
By now, you probably know Ptolemy’s theorem, which only works on cyclic quadrilaterals. However,
there are several other theorems and formulas that apply specifically to cyclic quadrilaterals because
of their circumscribing circle. The following theorem is probably the easiest and most simple one to
prove.
Theorem 1
The sum of opposite angles in cyclic quadrilaterals is always 180◦ .
l
ue B
m
A
Sa
Proof. Consider the following diagram. Notice how ∠ABC bounds the arc ADC. Therefore, we
can see that m∠ABC = mADC 2
from our arc length theorems. Also notice that the same applies to
m∠ADC = 2 . Therefore, m∠ABC + m∠ABC = mABC+mADC
mABC
2
= 360
2
= 180◦ . This applies
to all angles in the cyclic quadrilateral. It can also be proven that the converse of this theorem is
true.
Samuel Other Cyclic Quad Theorems 83
Example 1
Given that two angles in a cyclic quadrilateral measure 120◦ and 50◦ , determine the degree
measures of all other angles.
Since opposite angles must be supplementary, and 120 + 50 ̸= 180, the given angles are not opposite.
Therefore, we can determine that one of the missing angles is 180 − 120 = 60◦ , and the other is
180 − 50 = 130◦ .
Example 2
Let ABCD be a cyclic quadrilateral. The side lengths of ABCD are distinct integers less than
15 such that BC · CD = AB · DA. What is the largest possible value of BD?
l
Solution. By Law of Cosines,
BD2 = AD2 + AB 2 − 2(AD)(AB) cos(∠BAD)
ue
BD2 = CD2 + BC 2 − 2(CD)(BC) cos(∠BCD).
Since ABCD is cyclic, we have m∠BAD + m∠BCD = 180◦ , and 2(AD)(AB) cos ∠BAD =
−2(CD)(BC) cos ∠BCD. Add these up to get BD2 = AD2 + AB 2 + CD2 + BC 2 .
Now, try to make AD(AB) = CD(BC). If AB is 14, then BC or CD will be equal to 7. WLOG
BC = 7, then CD = 6, DA = 12. The maximum value of 2BD2 = 142 + 72 + 62 + 122 = 425, so
m
s
425
the maximum value of BD = .
2
Theorem 2
Sa
There isn’t really any proof required. This is simply true because the angles we claim to be equal
bound the same arc in the circle! However, this idea is very handy to keep in mind!
Example 3
Consider △ABC with m∠CAB = 45◦ and m∠BCA = 60◦ . Let BD be the angle bisector
of ∠ABC, where D is the point of intersection between AD and the circumcircle of △ABC.
Let E be the point opposite of D on the circumcircle of △ABC. Determine the measure of
∠EAC (TJ “Fake” Holiday CMIMC TST Problem 3).
Samuel Other Cyclic Quad Theorems 84
C
A
Solution. Since BD is the angle bisector of ∠ABC, we have that m∠ABD = m∠CBD =
l
(75/2)◦ = 37.5◦ . Also, m∠CBD = m∠CAD, so m∠CAD = 37.5◦ , and it bounds an 75◦ arc.
Theorem 3
ue
Since E is on the opposite side of D on the circumcircle, the arc bounded by DE must be a 180◦
arc. So, the measure of ∠EAC will be 180−75
2
q
, or 52.5 .
The area of a cyclic quadrilateral is (s − a)(s − b)(s − c)(s − d), where a, b, c, d are the
m
side lenghts of the quadrilateral, and s is the semiperimeter( a+b+c+d
2
). This is also known as
Brahmagupta’s Formula for the area of a Cyclic Quadrilateral.
The proof is extremely messy, but you can check it out here: Brahmagupta’s Formula Proof.
Sa
Also, Brahmagupta’s Formula is a special case of Bretschneider’s formula, when the cosine of the
sum of two opposite angles in a cyclic quadrilateral become zero(a nice application of theorem 1!)
Example 4
Quadrilateral ABCD with side lengths AB = 7, BC = 24, CD = 20, DA = 15 is inscribed
in a circle. The area interior to the circle but exterior to the quadrilateral can be written in the
form aπ−b
c
, where a, b, and c are positive integers such that a and c have no common prime
factor. What is a + b + c? (2023 AMC 10A Problem 15)
Solution. It is pretty easy to see that the diameter of this circle is 25 (you can verify this by using
the fact that 7–24–25 and 15–20–25 are both Pythagorean Triples, and then applying the converse
of Thales’s Theorem). Therefore, the area of the circumcircle is 625π 4
. Since the quadrilateral is
inscribed
q in a circle, it is cyclic. Brahmagupta’s formula tells us that the area of quadrilateral is
(33 − 7)(33 − 24)(33 − 20)(33 − 15) = 234. So, 625 4
π − 234 = 625π−936
4
, and our answer is 1565 .
Samuel Other Cyclic Quad Theorems 85
Theorem 4
All perpendicular bisectors of a cyclic quadrilateral are concurrent, and intersect at the circum-
center of the cyclic quadrilateral. The converse is also true.
Proof. Imagine each side as an individual chord in the circle. It is known that the perpendicular
bisector of the chord passes through the center of the circle. Since this applies to all four sides, all
perpendicular bisectors of a cyclic quadrilateral are concurrent at the circumcenter of the circle.
Example 5
Triangle ABC is an isosceles right triangle with AB = AC = 3. Let M be the midpoint of
hypotenuse BC. Points I and E lie on sides AC and AB, respectively, so that AI > AE and
l
AIM E is a cyclic quadrilateral. Given that triangle EM I has area 2, the length CI can be
√
ue
written as c , where a, b, and c are positive integers and b is not divisible by the square of
a− b
any prime. What is the value of a + b + c?(2018 AMC 12A Problem 20).
m
Example 6
Let ABCD be a cyclic quadrilateral with AB = 4, BC = 5, CD = 6, and DA = 7. Let A1
and C1 be the feet of the perpendiculars from A and C, respectively, to line BD, and let B1 and
D1 be the feet of the perpendiculars from B and D, respectively, to line AC. The perimeter
of A1 B1 C1 D1 is m , where m and n are relatively prime positive integers. Find m + n.(2021
Sa
n
AIME I Problem 11)
Example 7
Let ABC be an acute, scalene triangle, and let M , N , and P be the midpoints of BC, CA, and
AB, respectively. Let the perpendicular bisectors of AB and AC intersect ray AM in points
D and E respectively, and let lines BD and CE intersect in point F , inside of triangle ABC.
Prove that points A, N , F , and P all lie on one circle(USAMO 2008).
Incenter-Excenter
by MathDash Team
https://mathdash.com/maps/map/incenter-excenter
h
as
I
B C
hD
M
at
IA
Figure 4: Fact 5: BM = IM = CM = IA M
M
Proof: Well, if M is the midpoint of the arc BC, then BM and CM have equal angle measures.
So, ∠BAM = ∠CAM (both are half of the measures of the arc). Thus, M lies on the angle bisector
of ∠BAC. We know, by definition that I and IA lie on this angle bisector as well — (remember IA
is defined as the intersection of the A-angle bisector and the B, C external angle bisectors) — so we
MathDash Incenter-Excenter 87
We also know from M being the midpoint of the arc BC that BM = CM . Furthermore, note
that ∠IBM = ∠IBC + ∠CBM = 12 ∠ABC + ∠CAM = 12 ∠ABC + 12 ∠BAC = 90 − 12 ∠ACB.
Also, angle ∠BIM = 180 − ∠AIB = ∠BAI + ∠ABI = 21 ∠ABC + 12 ∠BAC = 90 − 21 ∠ACB.
So, ∠BIM = ∠IBM and thus BM = IM .
Furthermore, similar angle chasing gives us ∠M BIA = ∠CBIA − ∠CBM = 21 (180 − ∠ABC) −
∠CAM = 90 − 21 ∠ABC − 12 ∠BAC = 12 ∠ACB, and ∠M IA B = ∠ICB = 12 ∠ACB. So, M BIA
is isosceles and M B = M IA .
h
This theorem by itself is a very common configuration in advanced computational geometry and
olympiad geometry! Let’s use it to solve a problem
as
Example 1 (2013 HMMT Team #6)
Let triangle ABC satisfy 2 · BC = AB + AC, and have incenter I and circumcircle ω. Let D
be the intersection of AI and ω. If AI = 10, find DI.
hD
A
10
at
O
I
M
B
C
Solution: First, we can immediately tell that from the Incenter-Excenter Theorem, D, being
the intersection of AI with the circumcircle of ABC, is the midpoint of arc BC! This tells us
BD = CD = ID — so we simply need to find what this common length is. Let it be x.
h
as
hD
at
M
Math645 Introduction to Diophantine Equations 89
5
As you can probably tell, Diophantine Equations come in many forms. There is no standard
formula or algorithm for Diophantine Equations, as there is for quadratics or cubics. So, this chapter
will be very different, as there will be very few theorems, and mainly just methods.
4
h6
Anything in the form of ax + by = c, is a linear Diophantine Equation. To figure out when these
have roots, we have a theorem.
Proof: Recall that if and only if means we must prove the original statement and it’s inverse. We
start by proving the original statement: For integers a, b, there exist integer solutions for x and y
M
integers x, y such that ax + by = c. As we proved earlier, the gcd divides the left side of the equation
so it must divide the right side, which it doesn’t in this case, so there are no solutions.
Example 1
Two farmers agree that pigs are worth 300 dollars and that goats are worth 210 dollars. When
one farmer owes the other money, he pays the debt in pigs or goats, with "change" received in
the form of goats or pigs as necessary. (For example, a 390 dollar debt could be paid with two
pigs, with one goat received in change.) What is the amount of the smallest positive debt that
can be resolved in this way? (Source: 2006 AMC 10A Problem 22)
Solution: This problem can be reworked to the linear Diophantine Equation, 300x + 210y = c. Thus
5
with Bezout’s Lemma Extended, 30 | c, so the least positive value of c is 30
4
Now we try to find solutions to Diophantine Equations.
Theorem 2
h6
Once we have 1 solution to ax + by = c, if we increase x by kb
gcd(a,b)
, and decrease y by ka
gcd(a,b)
for any integer k, then we produce the entire solution set.
they must divide the left. Thus, all the divisors of b must divide am. a takes care of all the divisors
of b that are also divisors of gcd(a, b), thus all that is left are the divisors of gcd(a,b)
b
. So gcd(a,b)
b
| m.
Yet, 0 < m < gcd(a,b) , creating a contradiction, and we have proved that no other solutions exist.
b
Now, we only need to find 1 solution, which for small numbers can be obtained by guessing or for
larger numbers by applying the Euclidean Algorithm in reverse.
Recall, the Euclidean Algorithm takes two numbers, and constantly takes them modulo one another
until their greatest common divisor is reached. Now, instead of taking the values modulo, if we express
it as a quotient and a remainder, we form a linear combination. This will let us express it as a linear
diophantine equation, when we run it in reverse. If this sounds confusing, the example will clear it
up.
Math645 Introduction to Diophantine Equations 91
Example 2
Find a solution to 7x − 24y = 5
Solution: Once we find values of x and y, that make the 7x − 12y = 1, we can multiply x and y by 5
to finish. We chose 1 because it is gcd(7, 24), which we can create a solution for using the Euclidean
Algorithm in reverse. We start, (7, 24) = (7, 7 · 3 + 3) = (7, 3) = (3 · 2 + 1, 3) = (1, 3) = 1. Since 3
is a multiple of 1, we stop and now go in reverse, expressing 1 in the coefficients before it. We start
with the multiple
1=
3−2·1=
3 − 2 · (7 − 2 · 3)
5
(24 − 3 · 7) − 2 · (7 − 2(24 − 3 · 7)) =
24 · 5 − 17 · 7.
4
Since this may be confusing, we will show the process step by step. We start off with the very end of
our Euclidean Algorithm chain which is always the gcd, in this case 1. Then, since we have 2 values
that are a multiple of each other (which will always happen in the 2nd to last step of the Euclidean
h6
Algorithm), we express the gcd, in this case 1, with 3 and 1, pushing us back a step. Now we see we
obtained the 1 by expressing 7 as 3 · 2 + 1 so we can express 1 as 7 − 3 · 2, pushing us back a step.
Now we see we obtained the 3 by expressing 24 as 3 · 7 + 3 so we can express 3 as 24 − 3 · 7, pushing
us back a step. Finally, we combine like terms for 24 and 7, to finish. Thus 24 · 5 − 17 · 7 = 1, so
24 · 25 − 17 · 35 = 5, and (−35, 25) is a solution. Using the previous theorem, we also know that
(35 + 24k, 25 − 7k) are solutions.
at
Example 3
A class collects 50 dollars to buy flowers for a classmate who is in the hospital. Roses cost 3
M
dollars each, and carnations cost 2 dollars each. No other flowers are to be used. How many
different bouquets could be purchased for exactly 50 dollars? (Source: 2008 AMC 10B Problem
8)
Solution: This is just 3x + 2y = 50 for non-negative x, y. We start with the Euclidean Algorithm:
(3, 2) = (2 · 1 + 1, 2) = (1, 2) = 1. Now going backwards, 1 = 2 − 1 · 1 = 2 − 1 · (3 − 2) =
2 − 1 · 3 + 1 · 2 = 2 · 2 − 1 · 3, Thus x = −1, y = 2 is a solution if the equation is equal to 1. We
multiply by 50, and obtain x = −50, y = 100 is a solution. Yet they must both be non-negative. We
see that we can add 3 to y and subtract 2 from x to generate all solutions (by the previous theorem
since their gcd is 1). We need to make x positive, so we add the smallest multiple of 2 greater than or
equal to 50 which is just 50, so we must subtract 75 from y to get the solution x = 0, y = 25. Now
we continue generating as many as we can until one of them become negative. We can’t subtract
from x, so we add to x, subtracting from y. So, we stop when y becomes negative. Every time we
generate a solution, we subtract 3 from y, so our solutions happen by subtracting 0, subtracting 3,
Math645 Introduction to Diophantine Equations 92
subtracting 6 . . . all the way till subtracting the greatest multiple of 3 less than or equal to 25 which
is 24. It’s clear the sequence: 0, 3, 6, 9, . . . , 24 has 9 terms.
Example 4
Find the number of lattice points that the line 19x + 20y = 1909 passes through in Quadrant
I. (Source: 2008 iTest Problem 18)
Solution: This is just 19x+20y = 1909 for non-negative x, y. We start with the Eculidean Algorithm:
(19, 20) = (19, 19 · 1 + 1) = (19, 1) = 1. Going backwards, we obtain 1 = 19 − 18 · 1 = 19 −
18 · (20 − 19 · 1) = 19 − 18 · 20 + 19 · 18 = 19 · 19 − 18 · 20. Thus, (19, −18) is a solution for
5
it to be equal to 1. We multiply by 1909, to get the solution (19 · 1909, −18 · 1909). Now we try
to make y non-negative by repeatedly adding 19. However many times we add 19 to y, we must
subtract 20 from x. Now we see that if we add 19, 1909 times, we add 1909 · 19 to y and get 1909,
4
which is 100 more 19’s than what we want, which is the smallest value to generate all solutions. So
we only add 1809 19’s to bring the y to 1909 − 100 · 19 = 9. We subtract 20 · 1809 from x to
get the solution (19 · 1909 − 20 · 1809, 9). Now to generate all solutions, we continue adding 19 to
h6
y, subtracting 20 from x, until x becomes negative. Note that if we subtract another 100 20’s, we
obtain x = 19 · 1909 − 1909 · 20 = −1909. This is negative so we need to add back 1920 since adding
1900 makes it still negative and 1920 is the next smallest multiple of 20. Adding 1920 = 20 · 96,
gives us an x value of 19 · 1909 − 1909 · 20 + 20 · 96 = 19 · 1909 − 1813 · 20, being the smallest value of
x. The largest was 19 · 1909 − 1809 · 20, giving us a total of 5 non-negative solutions.
at
Example 5
Let n be the number of ways 10 dollars can be changed into dimes and quarters, with at least
one of each coin being used. Then n equals (Source: 1968 AHSME Problem 19)
M
Solution: This is just positive solutions to 10x + 25y = 1000, or dividing by 5 gives us 2x + 5y = 200.
While we can apply Euclidean Algorithm, as stated earlier another way to find your first solution is
to guess. It’s clear to see and guess that (100, 0) works, and we have our first solution. To bring it
to positive, we add 2 to y, and subtract 5 from x, to give (95, 2). For practice, we use the Euclidean
Algorithm. (2, 5) = (2, 2 · 2 + 1) = (2, 1) = 1. Backwards gives, 1 = 2 − 1 = 2 − (5 − 2 · 2) =
2 − 5 + 2 · 2 = 2 · 3 − 5 · 1 or (3, −1). Multipling by 200, gives (600, −200). We must add 2 to y,
until we reach positive so we add 202 in total since it’s the least multiple of 2 to bring us to positive.
We add 101 2’s to y, so we subtract 101 5’s from x, and obtain (95, 2), just like by guessing. Now,
to keep us in positives, we can subtract 5 from x, a maximum of 18 times since 19 will make x = 0.
So subtracting anything from 0 − 18 times gives us a total of 19 options or 19 solutions.
While linear diophantine equations have many uses, especially for problems like the above practice
problems, perhaps the most important use of Linear Diophantine Equations is modular division.
discussed in Modular Arithmetic I by Math645, modular division can be used a ton in advanced
Math645 Introduction to Diophantine Equations 93
Number Theory Problems. If you don’t know what modular division is, reading it’s section of Modular
Arithmetic I is vital.
With this problem, we will uncover many properties of modular division, so even if you know how to
solve, read the solution to uncover many modular divison properties, and methods.
5
division problem into a linear diophantine equation. Now it is clear to see that the fraction is only
defined when there exist solutions to this linear diophantine equation. There exist solutions only if
the greatest common divisor of d and n divides c. Thus every common divisor of d and n must divide
4
c. Yet since gcd(c, d) = 1, the only divisor of d that divides c is 1. And since every common divisor
of d and n must be a divisor of d (obviously) and c (stated earlier), every common divisor must be
1. So gcd(d, n) = 1 if and only if a solution exists. Now since the gcd is 1, solutions for x repeat
every gcd(d,n)
n
h6
= n so there is only 1 unique value mod n, and this produces all solutions.
Example 6
Solve the modular equation: x ≡ 6
12
mod 9.
at
Rookie Mistake: 6
12
≡ 1
2
mod 9. Fraction simplification isn’t a valid operation in modular arithmetic.
Solution: Multiply everything by 12 (Cross Multiply) to get 12x ≡ 6 mod 9. We see that gcd(12, 6)
isn’t 1 so we start removing common factors. The factor of 3 is shared, and 3 divides the modulo,
9, so when removing it by Division Case 1, we remove it from the modulo too to get 4x ≡ 2 mod 3.
M
This is the reason why the rookie mistake of fraction simplification failed. Next, we divide everything
by 2 with Division Case 2 so we don’t have to remove it from the modulus, to get 2x ≡ 1 mod 3 so
2x = 1 + 3y so 2x − 3y = 1 It is very easy to guess that x = 2 works so the solutions are x ≡ 2 mod
3, yet we solve the Linear Diophantine Equation anyways. 2x − 3y = 1 so the Euclidean Algorithm
gives (2, 3) = (2, 2 · 1 + 1) = (2, 1) = 1, and backwards: 1 = 2 − 1 · 1 = 2 − 1 · (3 − 2 · 1) = 2 · 2 − 3 · 1,
so x = 2 is a solution and x ≡ 2 mod 3 is the answer.
This solution path will always work for modular division mentioned in the Modular Arithmetic I chapter
by Math645.
Now, Diophantine Equations start to become fun, as there is no longer an algorithm or method to
solve Diophantine Equations. Not all Diophantine Equations are linear Diophantine Equations, and
Math645 Introduction to Diophantine Equations 94
they can have exponents, products of variables, more variables, elements which aren’t integers, and
more. For these Diophantine Equations which aren’t linear, there are 2 main ways of solving them:
Factoring, or taking all sides modulo a value. We start with Factoring.
Factoring
If we can factor a Diophantine Equation, into a part with products of variables on one side, and a
constant on the other side, we can consider integer factors of the constant, and apply those onto the
variables since if the variables are integers, expressions in terms of the variables are also integers, and
there are a limited number of integer factors of the constant.
5
Example 7
How many non-negative integer solutions for (x, y) exist to the equation: (x + 2)(y + 1) = 840.
4
Solution: This is already factored, and in the way we want it. So we just consider factors of 840.
For example, 7 is a factor of 840. If we assign 7 to (x + 2), then it’s clear that y + 1 = 120. Thus,
h6
we just got a solution for (x, y) from a factor of 840. This factor contributed 1 solution. Similarly
each factor will contribute 1 solution. But, how do we know there don’t exist solutions of (x, y) that
can’t be found by considering factors of 840. Simply, if x + 2 isn’t a factor of 840, then y + 1 is a
fraction and so is y, which isn’t possible. Thus we just need to find the number of positive integer
factors of 840, and consider some extreme cases. We can prime factorize it as 23 · 3 · 5 · 7, which as
covered in a previous chapter of the MathDash Book has 4 · 2 · 2 · 2 = 32 factors. However x and y
at
must be non-negative or x ≥ 0 and y ≥ 0. Thus, x + 2 ≥ 2 and y + 1 ≥ 1. Since the factors are
positive integers, there are no constraints on y + 1, but x + 2 can still be a positive integer while not
being greater than or equal to 2. This happens only when x + 2 = 1 and 1 is a factor of 840, so we
have to subtract this case since it has a negative value of x, but was still counted since x + 2 has a
positive value and factor of 840. So the answer is simply 32 − 1 = 31 .
M
Once we can get it to a factored form as the previous equation, it is simple, but how do we get
it to the factored form. This requires knowledge of many algebraic factorizations, and at times even
nice observations and guessing. We will now share some algebraic factorizations that help in factoring
Diophantine Equations, the proof of which requires Algebra so is left out.
We now look at a generalization of the previous theorem. The reason this was still kept despite
having a generalization, is because it is very important for competition math, and should be known
quick enough without having to apply the generalization.
5
Theorem 6 (Sum of odd powers general case)
a2n+1 + b2n+1 = (a + b)(a2n − a2n−1 b + a2n−2 b2 − . . . − ab2n−1 + b2n )
4
There doesn’t exist a general case for sum of even powers.
h6
Theorem 7 (Factor Theorem)
If a is a root of P (x) then x − a is a factor of P (x)
at
This means wherever we can calculate roots with Algebra, we can factor into a Diophantine Equation.
There are many more factoring theorems, yet these are the most important basics, and should be
understood deeply.
M
Example 8
The harmonic mean of two positive integers is the reciprocal of the arithmetic mean of their
reciprocals. For how many ordered pairs of positive integers (x, y) with x < y is the harmonic
mean of x and y equal to 620 ? (Source: 1996 AIME Problem 8)
Example 9
The integer solutions to the following equation are (x1 , y1 ) and (x2 , y2 ). Find x1 + x2 + y1 + y2
x2 + x + 1 = y 2 − 1
Hint: Move everything to one side and use the Quadratic Formula for x
Solution: Move everything to the left side and write as a Quadratic in x, to get x2 + x + (2 − y 2 ) = 0.
Note that x must be an integer so it must be rational, so the discriminant of this quadratic equation
must be a perfect square, lets call it m2 . Note that the discriminant is 4y 2 − 7 = m2 . Isolating
the constant, 7, we have 4y 2 − m2 = 7. Using difference of squares, we can factor this into
(2y − m)(2y + m) = 7. Note that y must be a positive integer and if m is positive 2y + m must be
positive. If m is negative 2y − m must be positive. So since one factor is positive, so is the other.
5
Thus we have 2 possibilities: 2y + m = 7 and 2y − m = 1 or 2y − m = 1 and 2y + m = 7. In both
cases we have y = 2 and m = ±3. Note that by the Quadratic Formula, x = −1±m 2
= −1±3
2
. So we
have x = 1, −2 and for each value, y = 2. So our answer is just 1 + 2 + (−2) + 2 = 3 .
Example 10
4
h6
How many integer solutions are there to a2 + 1 = b2 + 2024? (Source: 2024 SIMC 10)
Solution: Factor to (a − b)(a + b)=2023. 2023 has 6 factors. Negative factors work for a total of
12 solutions.
at
Example 11
Let f (x) be a cubic function with leading coefficient 1. If f (y) = f (−y) = f (3y) = 0 for an
integer y, find integer solutions to (x, y) for
a) f (x) = 12
M
b) f (x) = −2
c) f (x) = 3
see they differ by 2, so 2y = ±2. So y = ±1. If y = 1, then x = 0. If y = −1, then x = −2, giving
us the solutions, (0, 1) and (−2, −1).
Sometimes, there is no easy factoring trick, and instead you just have to experiment, try new
things, manipulate, and even guess factorings.
Example 12
Integers a, b, and c satisfy ab + c = 100, bc + a = 87, and ca + b = 60. What is ab + bc + ca?
(Source: 2024 AMC10A Problem 23)
Solution: As stayed earlier by trying many different manipulations, expirements, adding equations,
multiplying equations, and subtracting equations, you will find that by subtracting the second equation
5
from the first equation, we have ab + c − bc − a = 13. This can be factored as (b − 1)(a − c) = 13.
This gives us 4 cases since 13 has 2 positive integer factors, and 2 negative integer factors:
4
Case 1: b − 1=13 and a − c = 1. Then, b = 14, and a = c + 1. Then ac + b = c2 + c + 14 = 60,
so c2 + c = 46. This has no integer solutions.
h6
Case 2: b−1 = −13 and a−c = −1. Then b = −12, and c = a+1. Then ac+b = a2 +a−12 = 60,
so a2 + a = 72. a = 8, −9 is a solution. Thus, (8, −12, 9) and (−9, −12, −8) work. Plugging into
ab + c = 100, we see that only (−9, −12, −8) works, so ab + bc + ac = 108 + 96 + 72 = 276 . We
don’t need to test any other cases since we got something that works and the AMC’s only have 1
correct answer.
at
Try it Yourself!
https://mathdash.com/maps/map/diophantine-equations
https://mathdash.com/contest/Diophantine-Equations-All-in-One
M
-Problem
Math645 Orders 98
Orders
by Math645, Testsolved by Krithik and Anthony
Definition 1 (Order)
We define order as ordm n = x if x is the lowest positive integer such that nx ≡ 1 mod m. If
this is the case, we can say that the order of n mod m is x.
For example the ord8 3 = 2 since 32 ≡ 1 (mod 8) and no lower power of 3 is 1 (mod 8).
5
Example 1
Let’s calculate the order of 3 mod 10 or ord10 3
4
Solution: We start calculating powers of 3. 31 ≡ 3 ̸≡ 1, 32 ≡ 9 ̸≡ 1, 33 ≡ 27 ≡ 7 ̸≡ 1,
34 ≡ 81 ≡ 1 mod 10. Thus ord10 3 = 4
h6
Note that if gcd(m, n) > 1, then there are no solutions to nx ≡ 1 mod m, as n to any positive
power can never be 1 mod m. So for the rest of this chapter, whenever we have ordm n, we assume
m and n are relatively prime, unless otherwise stated.
There are several theorems using orders that can help us to calculate orders of numbers much
easier than brute forcing, and solve problems that seemingly have no connection to orders.
at
Theorem 1 (Order Theorem 1)
x(ordm x) ≡ 1 (mod m)
M
is clearly just xn . The right side is 1 to the power of an integer which is just 1. Simplifying we get,
xn ≡ 1 (mod m) and we are done.
Proof: We do a proof by contradiction. Assume, for sake of contradiction, that ordm x doesn’t divide
n.
Then n ̸≡ 0 mod ordm x, so we can express n as a(ordm x) + b where 0 < b < ordm x, and a and
b are integers.
Plugging this into the given gives us x(a∗(ordm x)+b) ≡ 1. Simplifying the left as follows:
5
Thus we have xb ≡ 1 mod m where 0 < b < ordm x. This goes against our definition of order since
the order is the SMALLEST positive integer with the criteria. Thus the assumption is wrong and our
proof by contradiction is complete.
4
The next theorem is very useful, and helps form connections between problems that don’t seem
to involve orders, with problems that require order.
h6
Theorem 4 (Order Theorem 4)
The exponents of n mod m repeat every ordm n and no sooner or later.
at
Proof: We calculate n(x+ordm n) mod m to see nx+ordm n ≡ nx ∗ nordm n ≡ nx ∗ 1 ≡ nx , and the order
is the smallest value for which this is true since the order is the smallest value a such that na ≡ 1
We continue the theorems section with 2 theorems that helps us calculate the order, and can be
used in multiple ways.
M
Proof: Simply plug in n = ϕ(m) into Order Theorem 3 and use Euler’s Totient Theorem. This helps
us calculate orders as we only have to check values that divide the totient.
Proof: First we prove that ordm b must be divisible by the order of b modulo paxx for all x. Then, we
prove it must be the least common multiple of these numbers. Let’s consider paxx for any arbitrary x.
We know that ax is the largest power of px that divides m. Let’s denote the order we are looking for,
ordm b = y. Now by Order Theorem 1, we know by ≡ 1 mod m. Thus splitting m into it’s prime
factors, we know by ≡ 1 mod paxx . By Order Theorem 4, we know that this is possible when y is a
multiple of ord(paxx ) b. We also know that when y is a multiple, it will work. Thus the smallest value
that is a multiple of each ord(paxx ) b, is the lcm of all ord(paxx ) b
Example 2
Problem 1: Given that x32 ≡ 513 (mod 514), find ord514 x
5
Solution: Located at the end of the chapter with the rest of the solutions.
4
If you were unable to solve the previous problem, understand the solution before attempting the
next one. It uses the same concept, but different numbers to test your understanding of the solution.
h6
If you did solve the previous problem, try solving the next one as quick as possible.
Example 3
Problem 2: Given that x81 ≡ 719 (mod 974), find ord974 x. It is also given that 7193 ≡ 1 mod
974.
at
Solution: Once again, as with the rest of the solutions to the problems, it’s at the end of the chapter.
Now that you should be comfortable with orders lets go into competition-style math problems
M
Example 4
Problem 3: Find the least odd prime factor of 20198 + 1 (Source: 2019 AIME I Problem 14).
Example 6
Problem 5: Find the smallest prime number p such that p2 | (n4 + 1) for some positive integer
n. (Inspiration: 2024 AIME I Problem 13).
Example 7
Problem 6: Find the least positive integer n such that when 3n is written in base 1432 , its two
right-most digits in base 143 are 01. (Source: 2018 AIME I Problem 11).
5
Example 8
Problem 7: How many positive integer multiples of 1001 can be expressed in the form 10j − 10i ,
4
where i and j are integers and 0 ≤ i < j ≤ 99? (Source: 2001 AIME II Problem 10).
h6
Example 9
Problem 8: The values of y that satisfy the following equation can be expressed as a mod b.
Find ab − a:
Further Exercises: If you want more practice problems after the MathDash contests listed above,
try 1982 USAMO Problem 4. If you know LTE, try 2021 JMC 10 Problem 25 and try solving the
Math645 Orders 102
original 2024 AIME I Problem 13, instead of the modified version given here. The solutions, being
easy to find online, aren’t included. If you want to test your knowledge and calculations of order, you
can think of random numbers, find their order, and use Order Calculator to check your work.
Solutions
Problem 1: Note that 513 ≡ −1 (mod 514), so we write our equation as x32 ≡ −1. Then we
square both sides to get x64 ≡ 1. Thus, applying Order Theorem 3 with n = 64 and m = 514, the
order must divide 64. So the order must be 1, 2, 4, 8, 16, 32, 64. Now we apply Order Theorem 2
with m = 514 and n = 32. Thus, if the order divides 32, x32 ≡ 1, which we know is false as given
in the problem. Thus, the order doesn’t divide 32, but does divide 64, so the order is simply 64 .
5
Problem 2: We cube both sides to get x243 ≡ 1. Thus, applying Order Theorem 3 with n = 243
and m = 974, the order must divide 243. So the order must be 1, 3, 9, 27, 81, 243. Now we apply
4
Order Theorem 2 with m = 974 and n = 81. Thus, if the order divides 81, x81 ≡ 1, which we know
is false as given in the problem. Thus, the order doesn’t divide 81, but does divide 243, so the order
is simply 243 .
h6
Problem 3: Let the least odd prime factor be p. Then, p | 20198 + 1 or 20198 + 1 ≡ 0 mod
p. Subtracting 1, we get 20198 ≡ −1 mod p. Using the same logic as in the previous problems,
we obtain ordp 2019 = 16. Thus using Order Theorem 5, with m = p and b = 2019, we obtain
16 | ϕ(p). Since p is prime, ϕ(p) = p − 1. Thus 16 | p − 1. We test multiples of 16, to see if they
at
are 1 less than a prime to quickly see that the smallest such primes are 17, 97, and 113. Now we
test all of them to see if they work, starting from the lowest since as soon as we have the smallest
value we are done.
Problem 4: We know p | a2 + 1 and since p is odd, p doesn’t divide 2, and thus p doesn’t divide
n
a2 +1 − 1 ≡ 0 mod p or a2 +1 ≡ 1 mod p. Combining this with a2 ̸≡ 1, and using the logic with
n n n
problem 1, we see that ordp a = 2n+1 . Applying Order Theorem 5 with m = p and b = a, we have
2n+1 | p − 1.
Problem 6: We can write the given statement as 3n ≡ 1 (mod 1432 ). Using Order Theorem 6, we
break it up and handle the 2 cases separately. We want the smallest n such that:
1. 3n ≡ 1 (mod 112 ). This is simply ord121 3, which we can calculate using Order Theorem 5
with m = 121 and b = 3. So b | ϕ(121) = 110. Thus, b = 1, 2, 5, 10, 11, 22, 55, 110. We start with
the lowest values and build our way up.
– 31 ≡ 3 ̸≡ 1
– 32 ≡ 9 ̸≡ 1
5
Thus, n must be a multiple of 5.
4
2. Now, we need the smallest n such that 3n ≡ 1 (mod 169). Thus, using Order Theorem 5,
n | 156. We also know that 3n ≡ 1 (mod 13). Trying values, we quickly get that the smallest n
for this is 3. Thus, with Order Theorem 2, we have 3 | n | 156. This limits n to 3, 6, 12, 39, 78,
h6
156. Once again, starting with the smallest values and working our way up mod 169. Although it is
tedious, we can constantly take mod 169 to get small numbers. We get:
– 33 ≡ 27 ̸≡ 1
– 36 ≡ 729 ≡ 53 ̸≡ 1
Thus using Order Theorem 6, we solve the least common multiple of 39 and 5 is 195 .
M
Problem 7: We need values of i and j such that 1001 | 10j −10i . We can rewrite this as 10j −10i ≡ 0
mod 1001 or 10j ≡ 10i mod 1001. Dividing by 10i , we obtain 10j−i ≡ 1 mod 1001. Using Order
Theorem 4, we know that they will repeat every ord1001 10 times, so we calculate this order.
101 ≡ 10 ̸≡ 1,
102 ≡ 100 ̸≡ 1,
103 ≡ 1000 ̸≡ 1
we have 94 values for j (7–100) and each value has 1 correspondent value of i. If j − i = 12, we
have 88 values for j (13–100) and each value corresponds to 1 value of i. Continuing the pattern,
we have 94 + 88 + 82 + 76 · · · + 4, and using arithmetic series formulas, we have 16∗(94+4)
2
, or 784 .
Problem 8: We divide both sides by 3y+2 to get our equation to 3y−2 ≡ 1 mod 221. Using Order
Theorem 4, it is clear to see that 30 ≡ 1 and they repeat every ord221 3 so the solutions are y − 2 ≡ 0
mod ord221 3. Thus, y ≡ 2 mod ord221 3. We calculate ord221 3 using Orders Theorems 4 and 6.
Firstly we factor 221. We realize it is 4 less than 225 so we can use difference of squares to see
that 221 = 225 − 4 = (15 − 2)(15 + 2) = 13 ∗ 17. Thus with Order Theorem 6, we calculate,
lcm(ord17 3, ord13 3).
1. To calculate ord17 3, we use Order Theorem 5. We see that since 17 is prime, ϕ(17) = 16,
Thus the order must be 1, 2, 4, 8, or 16. We test values starting from the smallest modulo 17.
5
31 ≡ 3 ̸≡ 1.
32 ≡ 9 ̸≡ 1.
34 ≡ 81 ≡ 13 ̸≡ 1.
4
38 ≡ (34 )2 ≡ 132 ≡ 169 ≡ −1 ≡ 16 ̸≡ 1. Thus the order must be 16 since it’s not 1, 2, 4, 8.
h6
2. To calculate ord13 3, we apply Order Theorem 5. We see that since 13 is prime, ϕ(13) = 12.
Thus the order must be 1, 2, 3, 4, 6, or 12. We test values from the smallest modulo 13.
31 ≡ 3 ̸≡ 1
32 ≡ 9 ̸≡ 1
at
33 ≡ 27 ≡ 1. Thus ord13 3 is 3 and ord221 3 = lcm(3, 16) = 48. So from earlier y ≡ 2 mod 48.
So a = 2, and b = 48. ab − a = 2 ∗ 48 − 2 = 96 − 2 = 94 .
M
MathDash AIME 105
AIME
by MathDash Community
https://mathdash.com/contests?tag=AIME
h
as
hD
at
M
Timur Functional Equations 106
Functional Equations
by Timur
https://mathdash.com/maps/map/functional-equations
Concepts
Let f : A → B be a function. The set A is called domain, and the set B the codomain. Now, let’s
look at a couple of definitions which will be useful:
Definition 1 ur
A function F : A → B is injective if f (x) = f (y) ⇐⇒ x = y.
m
Definition 2
A function F : A → B is surjective if for all b ∈ B, there exists at least one x such that
f (x) = b. (Sometimes also called onto).
Ti
Definition 3
A function is bijective if it is both injective and surjective.
Example
Example 1
Find all functions f : R → R such that
f (x) + xf (1 − x) = x
for all x ∈ R.
Timur Functional Equations 107
f (a) + af (1 − a) = a (1)
f (1 − a) + (1 − a)f (a) = 1 − a. (2)
Equating (3) and (4) and rearranging the terms, we find that
f (a)
af (a) − f (a) + =a
a
a2
f (a) = .
a2 − a + 1
Now you may ask in this step Is it over? No, we should verify our answer. As following:
f (x) + xf (1 − x) =
= 2
ur
x2
x2 − x + 1
x2
x −x+1
+ x
+ 2
(1 − x)2
(1 − x)2 − (1 − x) + 1
x3 − 2x2 + x
x −x+1
m
= x.
Remark. Now you may ask why should we recheck our answer. The answer is it may contradict to
other equations.
Ti
• Common things to plug in: Zero, x = y, anything that results in canceling an f (something)
term (such as plugging in (x, x1 ) in f (x) + f (y) = (xy − 1)f (x)f (y).
• Many expressions you’ll see are cyclic, i.e. the variables used in cycle. For example, if you see
f (x) + f ( x2 ) or f (x) + f (1 − x), you can also plug in x → x2 or x → 1 − x to get the same
expression.
Resources.
⋆ Chapters 3,4 of OTIS Excerpts by Evan Chen
Functional Equations
https://mathdash.com/maps/map/functional-equations
ur
m
Ti
Krithik Inequalities 109
Inequalities
by Krithik
Introduction to Inequalities
Inequalities are becoming increasingly common in math olympiads. In this chapter, we discuss the
most useful theorems as well as some techniques to solve inequalities.
Notation
Definition 1 (Homogeneity)
ik
Define a function, polynomial, or inequality as homogeneous if all its terms have the same
ith
degree.
cyc
Kr
X
f (xσ(1) , xσ(2) , . . . , xσ(n) ),
σ
where σ ranges over all cyclic permutations of (1, 2, . . . , n). A cyclic permutation is one that
simply shifts the numbers by some constant. For example, if we had 3 variables, a, b, and c,
a3 = a3 + b 3 + c 3
X
cyc
and
a2 b = a2 b + b2 c + c2 a.
X
cyc
sym
X
f (xσ(1) , xσ(2) , . . . , xσ(n) ),
σ
Krithik Inequalities 110
where σ ranges over all permutations of (1, 2, . . . , n). For example, if we had 3 variables, a, b,
and c,
a3 = 2a3 + 2b3 + 2c3
X
sym
and
a2 b = a2 b + b2 c + c2 a + ab2 + bc2 + ca2 .
X
sym
Definition 4 (Majorizing)
Let sequence p = (a1 , a2 , . . . , an ) majorize q = (b1 , b2 , . . . , bn ) if, for all integers i such that
1 ≤ i < n, the sum of the first i numbers in p is greater than the sum of the first i numbers
in q, and
a1 + a2 + · · · + an = b 1 + b 2 + · · · + b n .
This is denoted by p ≻ q.
Basic Inequalities
ik
ith
Trivial Inequality
This is the simplest inequality, yet it can be used to derive almost all the other, more complicated
ones.
Kr
AM-GM Inequality
Proof
We shall use a special type of induction called Cauchy Induction. To use Cauchy induction, we
must prove that
ik √
a1 + a2 ≥ 2 a1 a2 .
√
a1 + a2 + · · · + an ≥ n n a1 a2 . . . an
for all positive real numbers a1 , a2 , . . . , an . We can see that if we have numbers a1 , a2 , . . . , a2n are
ith
positive real numbers, then
a1 + a2 + · · · + a2n = (a1 + a2 + · · · + an ) + (an+1 + an+2 + · · · + a2n )
√ √
≥ n n a1 a2 . . . an + n n an+1 an+2 . . . a2n
√
≥ 2n 2n a1 a2 . . . a2n .
3) Assume that
√
Kr
a1 + a2 + · · · + an ≥ n n a1 a2 . . . an
for all positive real numbers a1 , a2 , . . . , an . We can let an = 1
(a
n−1 1
+ a2 + · · · + an−1 ) to get that
q
n
(a
n−1 1
+ a2 + · · · + an−1 ) ≥ n n a1 a2 . . . an−1 (a1 + a2 + · · · + an−1 )/(n − 1).
Raising this to the power of n and simplifying give
(a1 + a2 + · · · + an−1 )n−1 ≥ (n − 1)n−1 a1 a2 . . . an−1 .
The result is straightforward after this. ■
For any real numbers k1 and k2 , M (k1 ) ≥ M (k2 ) if k1 ≥ k2 . Equality occurs when a1 = a2 =
· · · = an .
Weighted AM-GM and Weighted Power Mean are generalizations of AM-GM that are far more
powerful but less commonly used. We shall prove these theorems later in this chapter.
ik
9x2 sin2 x+4
x sin x
for 0 < x < π.
ith
Solution
Example 2
Let a, b, c be positive real numbers such that
(a − a1 ) + (b − 1b ) + (c − 1c ) = 0.
Prove that a + b + c ≥ 3.
Solution
We know that
1
a+b+c= a
+ 1b + 1c ,
so
(a + b + c)2 = (a + b + c)( a1 + 1b + 1c ).
Krithik Inequalities 113
Cauchy-Schwarz Inequality
Proof
ik
ith
By AM-GM,
n
n X n
n X
a2i b2j + a2j b2i ≥
X X
2ai bi aj bj .
i=1 j=1 i=1 j=1
This simplifies to !2
n n n
! !
a2i b2i
X X X
2 ≥2 ai b i .■
i=1 i=1 i=1
Kr
Proof
By Cauchy-Schwarz,
!
a21 a22 a2
+ + · · · + n (b1 + b2 + · · · + bn ) ≥ (a1 + a2 + · · · + an )2 ,
b1 b2 bn
and the result follows immediately. ■
Krithik Inequalities 114
i=1 }j=1 be a doubly indexed sequence of nonnegative real numbers and let ω1 , ω2 , . . . ,
Let {{aij }m n
(a11 + a21 + · · · + am1 )ω1 (a12 + a22 + · · · + am2 )ω2 . . . (a1n + a2n + · · · + amn )ωn
The proof of Hölder’s inequality is very difficult and will not be presented in this chapter.
Example 3
Let a, b, c be positive real numbers such that
(a − a1 ) + (b − 1b ) + (c − 1c ) = 0.
Prove that a + b + c ≥ 3.
Solution
ik
ith
This is the exact same question we encountered earlier, but let’s prove it with Cauchy-Schwarz. We
know that
a + b + c = a1 + 1b + 1c ,
so
(a + b + c)2 = (a + b + c)( a1 + 1b + 1c ).
Kr
By Cauchy-Schwarz,
(a + b + c)( a1 + 1b + 1c ) = (1 + 1 + 1)2 = 32 .
Therefore, a + b + c ≥ 3. ■
In many advanced problems, we can use Hölder’s inequality to simplify the expressions.
Proof
By Hölder’s inequality,
! ! !
a a
a(a + 8bc) ≥ (a + b + c)3 .
2
X X X
√ √
cyc a2 + 8bc cyc a2 + 8bc cyc
Krithik Inequalities 115
These inequalities are extremely useful when dealing with multi-variable homogeneous inequalities.
However, we must first define a notation that we will use often when applying Muirhead.
Definition 5
Define
xa11 xa22 . . . xann .
X
[(a1 , a2 , . . . , an )] =
sym
ik
Now, we may state Muirhead’s Inequality.
[p] ≥ [q].
Not all homogeneous inequalities can be solved with Muirhead, though. This is where Schur’s
inequality can be helpful. Schur’s inequality only works on 3 variables, however.
Kr
ar (a − b)(a − c) ≥ 0.
X
cyc
We will prove this result later in the chapter. It is worth memorizing some special cases of Schur’s
inequality.
sym
Krithik Inequalities 116
a4 + b4 + c4 + abc(a + b + c) ≥ a3 b
X
sym
Calculus Inequalities
Technically, no high school olympiads ever require calculus, so this chapter is optional. However,
calculus can be used to solve difficult inequalities faster. The proofs of these inequalities are extremely
advanced and will not be presented.
ik
We must define some new terminology before introducing these inequalities.
Definition 6 (Convexity)
ith
Call a function f convex if f ′′ (x) ≥ 0.
Definition 7 (Concavity)
Call a function f concave if f ′′ (x) ≤ 0.
Kr
Definition 8 (Monotonicity)
Call a function f monotonically increasing if f ′ (x) > 0 for all x and monotonically de-
creasing if f ′ (x) < 0 for all x. A function is monotonic if it is either always monotonically
increasing or always monotonically decreasing.
Jensen’s Inequality
such that ω1 + ω2 + · · · + ωn = 1,
If f is concave, then
Solution
ik
Let f (x) = ln(x). We can see that f ′ (x) = x−1 , so
Prove theorem 4.
Solution
but since k1 is negative, this is equivalent to what we wanted to prove, completing the proof. ■
Karamata’s Inequality
This inequality is very powerful. It can usually help in smoothing variables, a technique we will learn
later in this chapter.
Theorem 13 (Karamata)
ik
Let a1 , a2 , . . . , an and b1 , b2 , . . . , bn be real number sequences such that (a1 , a2 , . . . , an ) ≻
ith
(b1 , b2 , . . . , bn ), and let f be a convex function.
If f is concave, then
More Techniques
Smoothing
This is when we manipulate the variables to bring the two sides of the inequality together until we
get something manageable. To use smoothing, we can prove that, after bringing two variables closer,
the two sides get closer, or by using Karamata’s inequality.
Proof
Assume FTSOC that a1 , a2 , . . . , an < 2. If all of the numbers are nonnegative, then
which gives a contradiction. Hence, at least one term is negative. Then, we can perform the following
algorithm: if there are two terms −x and −y that are negative, we may replace them with −(x + y)
and 0 and all of the conditions still hold. Using this, we can reduce the sequence to only one negative
number, −k. Then, we may use smoothing to convert all the nonnegative terms to 2. We know that
n ≤ a1 + · · · + an < 2(n − 1) − k,
Ordering
Definition 9
ik
Ordering is the technique where we order the variables in an inequality and use this order to
solve a problem.
ith
Example 8
Prove Theorem 9.
Kr
Proof
cyc
We can see that cr (c − b)(c − a), a − b, and ar (a − c) − br (b − c) are all positive, which proves the
inequality. ■
Substitution
We can often use substitution to help simplify the inequality. This can help extremely if we are given
some initial condition. Some common ones include the following.
Krithik Inequalities 120
Theorem 14
√ √
Let a, b, c be positive real numbers. If abc = k, then we can substitute a = x/y 3 k, b = y/z 3 k,
√
c = z/x 3 k.
Proof
√
3
√
3
√
3
abc = x
y
k yz k xz k = k. ■
Theorem 15
Let a, b, c be positive real numbers. If ab + bc + ca + 2abc = 1, then we can substitute a = x
y+z
,
y
b = x+z , and c = x+y
z
.
Proof
ik
ith
We can see that
X xy 2xyz
ab + bc + ca + 2abc = +
cyc (x + z)(y + z) (x + y)(y + z)(z + x)
!
1 X
= xy(x + y) + 2xyz
(x + y)(y + z)(z + x) cyc
= 1. ■
Kr
Theorem 16
Let a, b, c be positive real numbers. If a + b + c + 2 = abc, then we can substitute a = y+z
x
,
b = x+z
y
, and c = x+y
z
.
Proof
This is exactly the same as the previous substitution, but a, b, c are replaced by 1/a, 1/b, 1/c. ■
Homogenizing
If the problem gives a condition and asks to prove a non-homogeneous inequality, we can use this con-
dition to homogenize the inequality, and then solve the inequality without the condition.
Krithik Inequalities 121
Example 9
√
Given that, for x, y, z > 0, xyz = 3, prove that (x + y + z) 3 9 ≤ x3 + y 3 + z 3 .
Proof
√ 2
3
9 = (xyz) 3 , so the inequality we seek reduces to
2
(x + y + z)(xyz) 3 ≤ x3 + y 3 + z 3 ,
ik
Prove that for all positive real numbers a, b, c such that abc = 1,
X
cyc
a
a + b + ab3
≥ 1.
ith
Proof
We can use substitution. Let a = x/y, b = y/z, and c = z/x. We can see that, by substituting,
simplifying, and using Titu’s lemma, we can obtain
a x/y
Kr
X X
3
= 2 3
cyc a + b + ab cyc x/y + y/z + xy /z
X x2 z 4
=
cyc x2 z 4 + xy 2 z 3 + x2 y 3 z
( cyc xz 2 )2
P
≥P 2 4
P 2 3
cyc x z + 2 cyc xy z
= 1. ■
Given a function that we want to bound, we can find the line tangent to a point on the graph of
this function using calculus. We usually use the point that gives the equality case of our inequality.
Often, this tangent line either gives an upper bound or lower bound of the function.
Krithik Inequalities 122
ap + bq ≥ ap + bq ≥ 2a + 2b − 2e ≥ 2e (p + q) − 2e.
Proof
Let f (x) = xln x , g(x) = x ln x, h(x) = 2x − e, and j(x) = 2e ln x − e. Now, we need to prove that
ik
f (a) + f (b) ≥ g(a) + g(b) ≥ h(a) + h(b) ≥ j(a) + j(b).
Now, we shall prove that for all numbers x > 1 (although this is true for all positive real numbers),
ith
f (x) ≥ g(x) ≥ h(x) ≥ j(x).
First of all, it is easy to see that j ′ (x) = 2e/x and j ′′ (x) = −2e/x2 ≤ 0, so j(x) is concave.
Therefore, any tangent line to j(x) will be above the graph, and since j ′ (e) = 2e/e = 2 and
j(e) = h(e), h(x) is tangent to j(x). Therefore, h(x) ≥ j(x).
Now, we can see that g ′ (x) = ln x + 1 and g ′′ (x) = 1/x ≥ 0, so g(x) is convex and its tangent
Kr
line is below it. Therefore, since g ′ (e) = ln e + 1 = 2 and g(e) = h(e) h(x) is tangent to g(x), and
g(x) ≥ h(x).
It is left as an (easy) exercise to the reader to prove that the equality case happens if and only if
a = b = e and m = n = 1, and in this case,
ap + bq = ap + bq = 2a + 2b − 2e = 2e (p + q) − 2e = 2e.
Proof
After testing this function, we can see that (2, 2, 0, 0) appears to yield the maximum value of 23 . To
prove this, we can see that the tangent line to
1
f (x) =
x3 + 4
1 x
at x = 2 is − . We want a lower bound on this function, so we must prove that
4 12
1 1 x
≥ − .
x3 +4 4 12
Expanding and simplifying turns this into proving that
ik
!
X a X 1 b 1 1 1 2
3
≥ a − = (a+b+c+d)− (ab+bc+cd+ca) = 1− (a+c)(b+d) ≥ . ■
cyc b +4 cyc 4 12 4 12 12 3
Monotonicity (Calculus)
ith
To prove that f (x) ≥ f (y) for all x ≥ y, we can prove that f is monotonically increasing. We can
similarly prove the opposite inequality is f is monotonically decreasing.
Example 13
Kr
Proof
Taking the ln of both sides gives x − ln(x + 1) ≥ 0. The derivative of the LHS with respect to x
is negative, so this monotonically decreases. x = 0 gives that 1 ≥ 1, which is true, completing our
proof. ■
Extra Inequalities
Here are a few inequalities that are less important but can still be useful in some problems. You do
not need to memorize all of these, but it is good to know at least some of them.
Krithik Inequalities 124
ik
+ + ≥ .
b+c c+a a+b 2
Extra Problems
Example 14
Prove that xy + yz + zx ≤ x2 + y 2 + z 2 in as many ways as possible.
Proof
We can use the following different methods to prove this extremely simple inequality.
ik
ith
Try to prove it using all of these ways or as many as possible. All of the proofs are very straightforward.
Proof
By Titu’s Lemma,
X a2 (a + b + c)2 1 a2 + b 2 + c 2 3
≥ =1+ · ≥ . ■
cyc ab + ac 2(ab + bc + ca) 2 ab + bc + ca 2
Example 16
Prove the Cauchy-Schwarz using vectors.
Proof
√
Let a = z + y, and define b and c similarly. We can see that
xy + yz + zx = − 14 a4 + b4 + c4 + 1
2
a2 b2 + b2 c2 + c2 a2 ,
or
ik
a4 + b4 + c4 + a2 bc + ab2 c + abc2 − 2a2 b2 − 2b2 c2 − 2c2 a2 ≥ 0.
The polynomial on the LHS can be factored as
ith
(a + b + c)(a3 + b3 + c3 + 3abc − a2 b − ab2 − a2 c − ac2 − b2 c − bc2 ).
The problem now reduces to proving that this is positive. Because a, b„ and c are positive,
a + b + c ≥ 0,
or
a3 + b3 + c3 + 3abc ≥ a2 b + ab2 + a2 c + ac2 + b2 c + bc2 .
However, this is just Schur’s inequality (for t = 1), which completes the proof. ■
Proof
After expanding the numerator and simplifying the denominator, we get that the problem reduces to
proving
x4 + 2 x2 y 2
X X
cyc cyc 3
X X ≥ ,
x+2 xy + 3 4
cyc cyc
or
x4 + 8 x2 y 2 ≥ 3
X X X X
4 x+6 xy + 9.
cyc cyc cyc cyc
We can use the fact that xyz = 1 to homogenize this and get that we must prove
X 5 5 2 4 4 4
x4 + 8 x2 y 2 ≥ 3 x2 yz + 6
X X X
4 x 3 y 3 z 3 + 9x 3 y 3 z 3 .
ik
cyc cyc cyc cyc
4 4 4
x2 y 2 ≥ 9x 3 y 3 z 3 ,
X
3
cyc
or
X 5 5 2
x4 ≥
X
x3 y 3 z 3 .
cyc cyc
However, because (4, 0, 0) ≻ 5 5 2
, ,
3 3 3
, this is simply true by Muirhead’s inequality. ■
Krithik Inequalities 128
Proof
We can use ordering. Without loss of generality, let a ≥ b ≥ c. Our inequality to prove becomes
2(ab + bc + ca) + 4c2 ≥ a2 + b2 + c2 .
Because both the equation we are given and the inequality we must prove are homogeneous, we can
let c = 1. Now, we are trying to prove that
2ab + 2a + 2b + 4 ≥ a2 + b2 + 1,
and the given equation becomes
ik √
3
a + b = 4 ab − 1
Now, let m = ab and n = a + b. We are now trying to prove that
2m + 2n + 4 ≥ n2 − 2m + 1,
ith
which can be converted to
4m + 4 ≥ n2 − 2n + 1 = (n − 1)2 .
The equation given in the problem is now
√
n = 4 3 m − 1.
Substituting this gives that we must prove
Kr
1 2 1
4m + 4 ≥ (4m 3 − 2)2 = 16m 3 − 16m 3 + 4,
and after simplifying, we get that this is equivalent to proving
2 1
m ≥ 4m 3 − 4m 3 ,
or
1 2 1
m3 m3 − 4m 3 + 4 ≥ 0.
1
However, after dividing by m 3 and simplifying, we can see that we must prove
1
2
m3 − 2 ≥ 0,
which is true by the Trivial Inequality. ■
Resources
ik
ith
Kr
Krithik Monovariants and Invariants 130
Definition 1
An invariant is a value that does not change after doing a certain process or applying a certain
function. For example, assume we are playing a game where we can replace the numbers x and
y with x + y. In this game, the sum of the numbers never changes, so it is a invariant.
Definition 2
A monovariant is something that either always increases or always decreases. For example, if
√
we replaced x and y with 2 xy, the sum would always decrease by the AM-GM inequality, so
this would be a monovariant.
ik
ith
Example 1 (2024 AMC 10B Problem 16)
Jerry likes to play with numbers. One day, he wrote all the integers from 1 to 2024 on the
whiteboard. Then he repeatedly chose four numbers on the whiteboard, erased them, and
replaced them by either their sum or their product. (For example, Jerry’s first step might have
been to erase 1, 2, 3, and 5, and then write either 11, their sum, or 30, their product, on the
whiteboard.) After repeatedly performing this operation, Jerry noticed that all the remaining
numbers on the whiteboard were odd. What is the maximum possible number of integers on
Kr
Solution: Because the problem mentions finding the maximum possible value of something after
some process is performed, monovariants might work. After observing this operation be done on
some integers, we can get that the number of odd numbers always either stays constant or decreases,
making it a monovariant. Therefore, there can be at most 1012 odd numbers. However, we can see
that the number of numbers modulo 3 is an invariant, so the final answer must be 2 mod 3, giving
(A) 1010 .
Solution: The moment we see this problem, we can clearly see that invariants or monovariants can
be used. Furthermore, the square roots prompt us that there must be something squared in the
invariant. Looking closer, we can see that the sum of the squares of the terms is an invariant because
√
a2 + b2 + c2 = ( a2 + b2 + c2 )2 .
Therefore, the sum of squares must always be
12 + 22 + · · · + 102 = 385.
However, we can also see that the number of numbers modulo 2 is also invariant, so there must be 2
numbers when this process ends. To maximize the larger number, we must minimize the smaller one.
√ √
This can be done by making the smaller one 1, so the largest number remaining is 384 = 8 6 .
Many monovariant problems require some basic inequalities, so we will present some of the com-
mon, simple ones that often appear in monovariant problems.
Theorem 1 (AM-GM)
ik
For any positive integer n and positive real numbers a1 , a2 , . . . , an ,
√
a1 + a2 + · · · + an ≥ n n x 1 x 2 . . . x n
ith
Theorem 2 (Power-Mean Inequality)
For any positive integer n, positive real numbers a1 , a2 , . . . , an , and real numbers k1 > k2 ,
1 1
n n
! !
1X k1
1X k2
aki 1 ≥ aki 2 .
Kr
n i=1 n i=1
Example 3
The number 1 is written n times on a whiteboard, and on each turn, Krithik erases x and y and
replaces them with 4x + 4y. Prove that the number at the end of this process is at least n3 .
Solution: Let x be the last number and S be the sum of the cube roots of the numbers. We
√ √
can see that ( 12 ( 3 x + 3 y))3 ≤ 12 (x + y) by the Power Mean inequality, which is equivalent to
√ √ √ √
3
x + 3 y ≤ 3 4x + 4y. Therefore, S is always non-decreasing, so n ≤ 3 x, and we are done. ■
Krithik Monovariants and Invariants 132
Monovariants are also commonly used to prove that some process terminates. This works when
there are a finite number of possible values of some quantity, and this quantity always increases or
decreases.
Example 4
There are some rooms in a building with some people in them. Every hour, one person leaves
one room and enters another room with more people. Prove that at some point, this process
must terminate.
Solution: Consider the sum of the squares of the number of people in each room. We can see
that this is always increasing, but it has a finite number of possible values, so this process must end.
■
ik
Try some Monovariants/Invariants Practice Contests
Invariants Problem 1 (1500)
Invariants Problem 2 (1500)
ith
Invariants Problem 3 (2000)
Invariants Problem 4 (1900)
Invariants Problem 5 (2000)
Invariants Problem 6 (2000)
Invariants Problem 7 (2200)
Kr
Quadratic Residues
by MathDash Team
https://mathdash.com/maps/map/quadratic-residues
Definition 1
We define a to be a quadratic residue in mod m if there exists an integer x such that x2 ≡ a
(mod m)
h
Theorem 1
as
For every odd prime p, exactly half of {1, 2, · · · , p − 1} are quadratic residues and exactly half
are quadratic non-residues.
Solution: Consider all the nonzero residues modulo p, namely 1, 2, . . . , p − 1, and square them.
If two of the squares are equal, we have x21 ≡ x22 (mod p), or x21 − x22 = (x1 + x2 )(x1 − x2 ) ≡ 0
hD
(mod p). This means (x1 + x2 )(x1 − x2 ) is divisible by p, so one of the terms has to be divisible by
p! So, x1 is either x2 or −x2 modulo p.
What does this mean? Well, in our set of squares 12 , 22 , . . . , (p − 1)2 , this result means that two
of them are congruent modulo p if and only if they are the same square or they are in a x2 , (p − x)2
pair. Thus our set of squares must consist of p−1
2
distinct values, each occuring twice.
So, these p−1 distinct values are quadratic residues, and the other p−1
nonzero values are quadratic
at
2 2
nonresidues!
Now let’s describe some notation that will come in handy as we work a lot with quadratic residues
and nonresidues
M
Definition 2 (Legrende)
!
a
If p is an odd prime, a > 0, and gcd(a, p) = 1, the Legrende symbol is defined as
p
!
1, if a is a quadratic residue mod p,
a
= −1, if a is a quadratic nonresidue mod p,
p
if a is divisible by p.
0,
What an arbitrary definition right? Why would we define this.. Well, this symbol has some cool
properties.
MathDash Quadratic Residues 134
p−1
2
Proof: Well, we know that Fermat’s Little Theorem says that a 2 ≡ ap−1 ≡ 1 (mod p). So,
p−1
a 2 is either 1 or −1 modulo p (because if x2 ≡ 1, then (x + 1)(x − 1) ≡ 0 meaning x is 1 or −1
modulo p).
p−1
Which one is it? Well, suppose a is a quadratic residue. Then, a ≡ k 2 (mod p), so a 2 ≡
p−1
k p−1 ≡ 1. So, a being a quadratic residue means that a 2 ≡ 1 as desired!
h
Now, what if a is not a quadratic residue? This is a lot trickier to prove — I’m going to present
two proofs to this — one with some heavy machinery!
as
Theorem 3 (Lagrange’s Theorem)
If p is a prime, and f (x) is a polynomial of degree d with not all coefficients divisible by p, then
f (x) ≡ 0 (mod p) has at most d integer solutions in {0, 1, 2, · · · , p − 1}
hD
A quick sketch of the proof of Lagrange’s Theorem is to repeatedly use the division algorithm in
modulo p to divide out (x − r) for each solution r to this.
p−1
In any case, we can use Lagrange’s Theorem here because a 2 − 1 ≡ 0 already has p−1 2
roots,
p−1
namely all of the quadratic residues, so it must not have any other solution! So, a 2 must not be 1
for a any quadratic nonresidue, meaning it is −1. This proves the result!
Here’s another proof: Consider the set of residues {1, 2, · · · , p − 1}. Let us pair each residue r
at
with a · r−1 . Notice since a is not a quadratic residue, each residue is paired with a different nonzero
residue. Additionally, the product of each pair of residues is a, so the total product is a(p−1)/2 .
However, the product is also (p − 1)! (mod p). So, we just need to show now that (p − 1)! ≡ −1
(mod p), and this is exactly the statement of Wilson’s Theorem.
M
p−1
Now that we’ve shown a 2 ≡ 1 (mod p) for quadratic residues a, and −1 (mod p) for quadratic
nonresidues a, we have proved Euler’s Criterion.
One nice property of the Legrende symbol follows immediately from Euler’s Criterion
Theorem 4
For p an odd prime, and gcd(a, p) = gcd(b, p) = 1,
! ! !
ab a b
=
p p p
Theorem 6
h
If p is an odd prime, then !
2 p2 −1
= (−1) 8
p
as
The proof of these statements is not simple — perhaps we will add a proof into here in the future
— but for now, let’s begin using these to solve a lot of number theory questions!
hD
Example 1
Show that for every prime number p there exists integers a, b such that a2 + b2 + 1 is divisible
by p
All we needed was an understanding of the number of possible values a2 and b2 could be to do
this one! Let’s do another.
M
Example 2
Find all integers x such that x2 − 31x + 34 is divisible by 37.
Example 3
Does there exist a positive integer x such that x2 leaves a remainder of 74 when divided by
131?
Solution: The Law of Quadratic Reciprocity is going to come in handy here. We compute as
follows:
74 2 37
=
131 131 131
131
18·65
= (−1) · (−1)
37
h
20
= (−1)
37
5
= (−1)
37
as
37
= (−1)(−1)18·2
5
2
= (−1)
5
= (−1)(−1)
hD
=1
So, indeed there does exist a positive integer x that satisfies this.
Example 4
Find the sum of all primes 5 ≤ p ≤ 30 for which there exist an x such that x2 + 3 is divisible
at
by p.
p p p p
p p p
= . Furthermore, is 1 only if p is 1 modulo 3 (we know this from checking the
3 3 3
two possible residues modulo 3 to see if they are quadratic residues). Thus, only primes that are 1
(mod 3) have −3 as a quadratic residue. This gives us an answer of 7 + 13 + 19 = 39 .
Example 5
If p = 2n + 1, n ≥ 2, p is prime, then find the remainder when 3(p−1)/2 is divided by p.
h
as
hD
at
M