Chapter 25. Modular Arithmetic
Chapter 25. Modular Arithmetic
Modular Arithmetic
Video Lectures
Modular Arithmetic Euler’s & Binomial Theorems Chinese Remainder Theorem & Line
Definition 25.0.1.
n ≡ a (mod b)
means the number ’n’ leaves the same remainder as ’a’ when divided by b
Theorem 25.0.2
If a = x (mod n) and b ≡ y (mod n), then
ab ≡ xy (mod n)
Theorem 25.0.3
If a ≡ x (mod n), then
am ≡ x m (mod n)
Video Solution
Video Solution
271
OmegaLearn.org Chapter 25. Modular Arithmetic
Video Solution
then
1 1 1
! ! !
ϕ(n) = n · 1 − 1− ... 1 −
p1 p2 pn
where ϕ(n) denotes the number of positive integers less than or equal to n that are
relatively prime to n.
Steps to find totient of a number
aϕ(n) ≡ 1 (mod n)
if and only if
gcd(a, n) = 1
272
OmegaLearn.org Chapter 25. Modular Arithmetic
ap−1 ≡ 1 (mod p)
if an only if p is a prime and
gcd(a, n) = 1
ab ≡ 1 (mod n)
(p − 1)! ≡ p − 1 ≡ −1 (mod p)
Video Solution
273
OmegaLearn.org Chapter 25. Modular Arithmetic
Video Solution
x ≡ a1 (mod n1 )
x ≡ a2 (mod n2 )
..
.
x ≡ ak (mod nk )
where all ni are relatively prime, then x has a unique solution (mod n1 · n2 · n3 . . . nk )
Remark 25.0.12
Be careful! This may not necessarily be true if any ni share common factors as then
congruences might contradict each other.
• Guess and Check until you reach a value that works and satisfies both mods
• Algebraic Method
1. Find 2 congruences
n ≡ r1 (mod m1 )
n ≡ r2 (mod m2 )
such that m1 and m2 are relatively prime
2. Rewrite them algebraically
n = k(m1 ) + r1
274
OmegaLearn.org Chapter 25. Modular Arithmetic
n = j(m2 ) + r2
3. Set them equal mod the smaller of m1 and m2 (in this case, say m1 < m2 )
k −1 (mod m2 )
n = k(m1 ) + r1
Concept 25.0.14
The solution to
n ≡ r1 (mod m1 )
n ≡ r2 (mod m2 )
is
n ≡ r1 + m1 (r2 − r1 ) · i
where i ≡ m−1
1 (mod m2 )
Remark 25.0.15
To solve a general congruence of more than 2 congruences, just solve them 2 at a time
until you are left with just 1 congruence.
Example 25.6
Find the smallest positive integer greater than 100 that leaves a remainder of 5 when
divided by 9 and leaves a remainder of 4 when divided by 17.
Video Solution
275
OmegaLearn.org Chapter 25. Modular Arithmetic
Video Solution
Video Solution
Problem 25.1.2
Video Solution
Problem 25.1.3
Video Solution
276
OmegaLearn.org Chapter 25. Modular Arithmetic
Video Solution
Video Solution
Problem 25.1.6
Find the smallest positive number that leaves a remainder of 11 when divided by
13 and a remainder of 2 when divided by 5.
Video Solution
Video Solution
Which of the following expressions is never a prime number when p is a prime number?
(A) p2 + 16 (B) p2 + 24 (C) p2 + 26 (D) p2 + 46 (E) p2 + 96
Video Solution
277
OmegaLearn.org Chapter 25. Modular Arithmetic
Let S(n) equal the sum of the digits of positive integer n. For example, S(1507) = 13.
For a particular positive integer n, S(n) = 1274. Which of the following could be the
value of S(n + 1)?
Video Solution
a1 + a2 + · · · + a2018 = 20182018 .
Video Solution
How many of the first 2018 numbers in the sequence 101, 1001, 10001, 100001, . . . are
divisible by 101?
a1 + a2 + · · · + a2018 = 20182018 .
278
OmegaLearn.org Chapter 25. Modular Arithmetic
Video Solution
One of the following numbers is not divisible by any prime number less than 10. Which
is it? (A) 2606 − 1 (B) 2606 + 1 (C) 2607 − 1 (D) 2607 + 1 (E) 2607 + 3607
Video Solution
k=0
Suppose 7Sn ≡ 1 (mod 2 ) for all n ≥ 1. What is the value of the sum
n
Video Solution
Additional Problems
Problem 25.1.17 (AMC 10)
279
OmegaLearn.org Chapter 25. Modular Arithmetic
(A) 21002 (B) 21003 (C) 21004 (D) 21005 (E) 21006
Let n be a 5-digit number, and let q and r be the quotient and the remainder, re-
spectively, when n is divided by 100. For how many values of n is q + r divisible by
11?
How many distinct four-digit numbers are divisible by 3 and have 23 as their last
two digits?
For positive integers N and k, define N to be k-nice if there exists a positive inte-
ger a such that ak has exactly N positive divisors. Find the number of positive integers
less than 1000 that are neither 7-nice nor 8-nice.
Let S be the set of integers between 1 and 240 whose binary expansions have exactly two
1’s. If a number is chosen at random from S, the probability that it is divisible by 9 is
p/q, where p and q are relatively prime positive integers. Find p + q.
280
OmegaLearn.org Chapter 25. Modular Arithmetic
The number obtained from the last two nonzero digits of 90! is equal to n. What
is n?
Answers
25.1 109
25.2 13
25.3 6
25.4 035
25.5 6
25.6 140
25.7 937
25.1.1 1
25.1.2 −1
25.1.3 343
4
25.1.4 5
25.1.5 15
25.1.6 37
25.1.7 0
281
OmegaLearn.org Chapter 25. Modular Arithmetic
25.1.8 0
25.1.10 1239
25.1.11 4
25.1.12 505
25.1.13 4
25.1.14 9
25.1.15 2607 − 1
25.1.16 6
25.1.17 4
25.1.18 21005
25.1.19 8181
25.1.20 30
25.1.21 749
25.1.22 913
25.1.23 112
25.1.24 239
25.1.25 12
282