100% FREE Updated: Mar 2026 Number Theory Fundamentals of Number Theory

Modular Arithmetic

Comprehensive study notes on Modular Arithmetic for CMI Data Science preparation. This chapter covers key concepts, formulas, and examples needed for your exam.

Modular Arithmetic

Overview

Welcome to the chapter on Modular Arithmetic, a foundational concept in Number Theory that is indispensable for a wide array of applications in computer science and data science. At its core, modular arithmetic is about working with integers and their remainders after division, effectively creating a system where numbers "wrap around" upon reaching a certain value. This cyclical nature allows us to model phenomena that repeat, manage finite data structures, and perform computations efficiently within constrained systems.

For your CMI studies, a solid grasp of modular arithmetic is not merely academic; it's a critical skill for understanding and solving problems in computational mathematics. You'll find its principles underpinning essential data science domains such as cryptography (e.g., public-key encryption, hashing algorithms), error detection and correction codes, random number generation, and efficient data indexing. Proficiency in this area is frequently tested in CMI examinations, not just for direct application but also as a fundamental tool for tackling more complex algorithmic and computational challenges. Mastering this chapter will equip you with a powerful mathematical toolkit, enhancing your problem-solving capabilities and preparing you for advanced topics in secure data handling and efficient algorithm design.

---

Chapter Contents

| # | Topic | What You'll Learn |
|---|-------|-------------------|
| 1 | Congruence Relations | Define congruence and explore its fundamental properties. |
| 2 | Operations in Modular Arithmetic | Perform addition, subtraction, multiplication, and division. |

---

Learning Objectives

❗ By the End of This Chapter

After studying this chapter, you will be able to:

  • Define and apply the concept of congruence modulo nn, and identify its fundamental properties.

  • Perform addition, subtraction, and multiplication operations within modular systems.

  • Compute modular multiplicative inverses and utilize them for modular division.

  • Apply modular arithmetic techniques to solve problems involving integer properties and computational cycles.

---

Now let's begin with Congruence Relations...

Part 1: Congruence Relations

Introduction

Congruence relations form a fundamental building block in number theory, providing a powerful framework for analyzing divisibility and remainders. This topic is essential for the CMI Masters in Data Science exam as it underpins various algorithms and theoretical concepts in cryptography, error-correcting codes, and computational number theory. Understanding congruence allows us to simplify complex arithmetic problems by focusing on the properties of integers modulo a given number. These notes will cover the core definitions, properties, and applications of congruence relations, preparing you to tackle diverse problems in the CMI exam effectively.
πŸ“– Congruence Relation

Let a,ba, b be integers and mm be a positive integer. We say that aa is congruent to bb modulo mm, written as a≑b(modm)a \equiv b \pmod m, if mm divides the difference aβˆ’ba-b.

Mathematically, this means:

m∣(aβˆ’b)β€…β€ŠβŸΊβ€…β€Šaβˆ’b=kmΒ forΒ someΒ integerΒ km \mid (a-b) \iff a-b = km \text{ for some integer } k

Equivalently, aa and bb have the same remainder when divided by mm.

a=q1m+randb=q2m+ra = q_1m + r \quad \text{and} \quad b = q_2m + r

where 0≀r<m0 \le r < m.

---

---

Key Concepts

1. Definition and Basic Properties

The congruence relation a≑b(modm)a \equiv b \pmod m establishes an equivalence relation on the set of integers Z\mathbb{Z}.

Properties of Congruence:

  • Reflexivity: For any integer aa, a≑a(modm)a \equiv a \pmod m.

  • Explanation:* aβˆ’a=0a-a = 0, and mm divides 00 (since 0=0β‹…m0 = 0 \cdot m).

  • Symmetry: If a≑b(modm)a \equiv b \pmod m, then b≑a(modm)b \equiv a \pmod m.

  • Explanation:* If m∣(aβˆ’b)m \mid (a-b), then aβˆ’b=kma-b=km. This implies bβˆ’a=βˆ’km=(βˆ’k)mb-a = -km = (-k)m, so m∣(bβˆ’a)m \mid (b-a).

  • Transitivity: If a≑b(modm)a \equiv b \pmod m and b≑c(modm)b \equiv c \pmod m, then a≑c(modm)a \equiv c \pmod m.

  • Explanation:* If m∣(aβˆ’b)m \mid (a-b) and m∣(bβˆ’c)m \mid (b-c), then aβˆ’b=k1ma-b = k_1m and bβˆ’c=k2mb-c = k_2m for some integers k1,k2k_1, k_2.
    Adding these equations: (aβˆ’b)+(bβˆ’c)=k1m+k2m(a-b) + (b-c) = k_1m + k_2m
    aβˆ’c=(k1+k2)ma-c = (k_1+k_2)m

    Since k1+k2k_1+k_2 is an integer, m∣(aβˆ’c)m \mid (a-c), so a≑c(modm)a \equiv c \pmod m.

    Algebraic Properties:

    If a≑b(modm)a \equiv b \pmod m and c≑d(modm)c \equiv d \pmod m, then:

  • Addition: a+c≑b+d(modm)a+c \equiv b+d \pmod m.

  • Explanation:* (a+c)βˆ’(b+d)=(aβˆ’b)+(cβˆ’d)(a+c)-(b+d) = (a-b)+(c-d). Since m∣(aβˆ’b)m \mid (a-b) and m∣(cβˆ’d)m \mid (c-d), mm divides their sum.

  • Subtraction: aβˆ’c≑bβˆ’d(modm)a-c \equiv b-d \pmod m.

  • Explanation:* Similar to addition, mm divides (aβˆ’b)(a-b) and mm divides (cβˆ’d)(c-d), so mm divides (aβˆ’b)βˆ’(cβˆ’d)(a-b)-(c-d).

  • Multiplication: ac≑bd(modm)ac \equiv bd \pmod m.

  • Explanation:* acβˆ’bd=acβˆ’bc+bcβˆ’bd=c(aβˆ’b)+b(cβˆ’d)ac-bd = ac-bc+bc-bd = c(a-b) + b(c-d). Since m∣(aβˆ’b)m \mid (a-b) and m∣(cβˆ’d)m \mid (c-d), mm divides both terms, and thus their sum.

  • Exponentiation: an≑bn(modm)a^n \equiv b^n \pmod m for any positive integer nn.

  • Explanation:* This follows from repeated application of the multiplication property.

  • Division (with caution): If ac≑bc(modm)ac \equiv bc \pmod m, then a≑b(modm/gcd⁑(c,m))a \equiv b \pmod{m/\gcd(c,m)}.

  • Explanation:* If ac≑bc(modm)ac \equiv bc \pmod m, then m∣c(aβˆ’b)m \mid c(a-b). Let d=gcd⁑(c,m)d = \gcd(c,m). Then m=dβ‹…mβ€²m = d \cdot m' and c=dβ‹…cβ€²c = d \cdot c' where gcd⁑(cβ€²,mβ€²)=1\gcd(c',m')=1.
    So dβ‹…mβ€²βˆ£dβ‹…cβ€²(aβˆ’b)d \cdot m' \mid d \cdot c' (a-b), which implies mβ€²βˆ£cβ€²(aβˆ’b)m' \mid c'(a-b).
    Since gcd⁑(cβ€²,mβ€²)=1\gcd(c',m')=1, we must have mβ€²βˆ£(aβˆ’b)m' \mid (a-b).
    Thus, a≑b(modmβ€²)a \equiv b \pmod{m'}, or a≑b(modm/gcd⁑(c,m))a \equiv b \pmod{m/\gcd(c,m)}.
    Crucial point: If gcd⁑(c,m)=1\gcd(c,m)=1, then a≑b(modm)a \equiv b \pmod m. This means we can "divide by cc" if cc is coprime to mm.

    Worked Example:

    Problem: Find the remainder when 21002^{100} is divided by 33.

    Solution:

    Step 1: Simplify the base modulo 33.

    2β‰‘βˆ’1(mod3)2 \equiv -1 \pmod 3

    Step 2: Apply the exponentiation property.

    2100≑(βˆ’1)100(mod3)2^{100} \equiv (-1)^{100} \pmod 3

    Step 3: Evaluate the result.

    (βˆ’1)100=1(-1)^{100} = 1
    2100≑1(mod3)2^{100} \equiv 1 \pmod 3

    Answer: 11

    ---

    2. Residue Classes and Systems

    The congruence relation partitions the set of integers Z\mathbb{Z} into disjoint sets called residue classes (or congruence classes) modulo mm. Each residue class consists of all integers that have the same remainder when divided by mm.

    πŸ“– Residue Class

    For an integer aa and a positive integer mm, the residue class of aa modulo mm, denoted by [a]m[a]_m or aˉ\bar{a}, is the set of all integers congruent to aa modulo mm:

    [a]m={x∈Z∣x≑a(modm)}[a]_m = \{x \in \mathbb{Z} \mid x \equiv a \pmod m\}

    [a]m={a+km∣k∈Z}[a]_m = \{a + km \mid k \in \mathbb{Z}\}

    For example, modulo 33, the residue classes are:
    [0]3={…,βˆ’6,βˆ’3,0,3,6,… }[0]_3 = \{\dots, -6, -3, 0, 3, 6, \dots\}
    [1]3={…,βˆ’5,βˆ’2,1,4,7,… }[1]_3 = \{\dots, -5, -2, 1, 4, 7, \dots\}
    [2]3={…,βˆ’4,βˆ’1,2,5,8,… }[2]_3 = \{\dots, -4, -1, 2, 5, 8, \dots\}

    Complete Residue System:
    A set of integers {r1,r2,…,rm}\{r_1, r_2, \dots, r_m\} is called a complete residue system modulo mm if every integer is congruent to exactly one element in the set. The most common complete residue system is {0,1,2,…,mβˆ’1}\{0, 1, 2, \dots, m-1\}, which are the least non-negative residues.

    Worked Example:

    Problem: Identify the complete residue system modulo 55 from the set {βˆ’10,βˆ’3,2,9,16}\{-10, -3, 2, 9, 16\}.

    Solution:

    Step 1: Find the least non-negative residue for each element modulo 55.

    βˆ’10≑0(mod5)-10 \equiv 0 \pmod 5
    βˆ’3≑2(mod5)-3 \equiv 2 \pmod 5
    2≑2(mod5)2 \equiv 2 \pmod 5
    9≑4(mod5)9 \equiv 4 \pmod 5
    16≑1(mod5)16 \equiv 1 \pmod 5

    Step 2: Check if the set of residues forms {0,1,2,3,4}\{0, 1, 2, 3, 4\}.

    The set of residues is {0,2,2,4,1}\{0, 2, 2, 4, 1\}. This set contains 22 twice and misses 33.

    Answer: The given set is not a complete residue system modulo 55 because it contains duplicate residues (22) and misses one residue (33). A valid complete residue system would be {0,1,2,4,16}\{0, 1, 2, 4, 16\} or {βˆ’10,16,2,9,βˆ’1}\{-10, 16, 2, 9, -1\}.

    ---

    3. Modular Arithmetic Operations

    Modular arithmetic is the system of arithmetic for integers, where numbers "wrap around" when reaching a certain valueβ€”the modulus. This is precisely the arithmetic of residue classes.

    Operations on Residue Classes:

    If [a]m[a]_m and [b]m[b]_m are two residue classes modulo mm, their sum, difference, and product are defined as:

  • Addition: [a]m+[b]m=[a+b]m[a]_m + [b]_m = [a+b]_m

  • Subtraction: [a]mβˆ’[b]m=[aβˆ’b]m[a]_m - [b]_m = [a-b]_m

  • Multiplication: [a]mβ‹…[b]m=[ab]m[a]_m \cdot [b]_m = [ab]_m
  • These operations are well-defined, meaning the result does not depend on the choice of representatives aa and bb from their respective classes.

    Worked Example:

    Problem: Calculate (17+23)(mod7)(17 + 23) \pmod 7 and (17Γ—23)(mod7)(17 \times 23) \pmod 7.

    Solution:

    Step 1: Simplify the numbers modulo 77.

    17≑3(mod7)17 \equiv 3 \pmod 7
    23≑2(mod7)23 \equiv 2 \pmod 7

    Step 2: Perform addition modulo 77.

    17+23≑3+2(mod7)17 + 23 \equiv 3 + 2 \pmod 7
    17+23≑5(mod7)17 + 23 \equiv 5 \pmod 7

    Step 3: Perform multiplication modulo 77.

    17Γ—23≑3Γ—2(mod7)17 \times 23 \equiv 3 \times 2 \pmod 7
    17Γ—23≑6(mod7)17 \times 23 \equiv 6 \pmod 7

    Answer: (17+23)(mod7)=5(17 + 23) \pmod 7 = 5 and (17Γ—23)(mod7)=6(17 \times 23) \pmod 7 = 6.

    ---

    ---

    4. Solving Linear Congruences

    A linear congruence is an equation of the form ax≑b(modm)ax \equiv b \pmod m. Solving this means finding all integers xx that satisfy the congruence.

    πŸ“ Solving Linear Congruences

    The linear congruence ax≑b(modm)ax \equiv b \pmod m has solutions if and only if gcd⁑(a,m)\gcd(a,m) divides bb.
    If gcd⁑(a,m)=d\gcd(a,m) = d and d∣bd \mid b, then there are exactly dd incongruent solutions modulo mm.
    These solutions can be found by first solving the reduced congruence:

    adx≑bd(modmd)\frac{a}{d}x \equiv \frac{b}{d} \pmod{\frac{m}{d}}

    This reduced congruence has a unique solution modulo m/dm/d. Let this unique solution be x0x_0.
    Then the dd incongruent solutions modulo mm are:
    xk=x0+k(md)(modm)forΒ k=0,1,…,dβˆ’1x_k = x_0 + k \left(\frac{m}{d}\right) \pmod m \quad \text{for } k=0, 1, \dots, d-1

    Variables:

      • a,ba, b: Integers

      • mm: Positive integer modulus

      • xx: Integer variable to solve for

      • dd: gcd⁑(a,m)\gcd(a,m)


    When to use: When finding integer solutions to equations involving congruences.

    Modular Inverse:
    If ax≑1(modm)ax \equiv 1 \pmod m has a solution, xx is called the modular multiplicative inverse of aa modulo mm. This exists if and only if gcd⁑(a,m)=1\gcd(a,m)=1. If an inverse aβˆ’1a^{-1} exists, then ax≑b(modm)ax \equiv b \pmod m can be solved by multiplying both sides by aβˆ’1a^{-1}: x≑aβˆ’1b(modm)x \equiv a^{-1}b \pmod m. Extended Euclidean Algorithm is commonly used to find modular inverses.

    Worked Example:

    Problem: Solve the linear congruence 6x≑9(mod15)6x \equiv 9 \pmod{15}.

    Solution:

    Step 1: Calculate d=gcd⁑(a,m)d = \gcd(a,m).

    a=6,m=15β€…β€ŠβŸΉβ€…β€Šgcd⁑(6,15)=3a=6, m=15 \implies \gcd(6,15) = 3

    Step 2: Check if dd divides bb.

    b=9β€…β€ŠβŸΉβ€…β€Š3∣9b=9 \implies 3 \mid 9
    Since 3∣93 \mid 9, there are 33 incongruent solutions modulo 1515.

    Step 3: Solve the reduced congruence.

    Divide a,b,ma, b, m by d=3d=3:

    63x≑93(mod153)\frac{6}{3}x \equiv \frac{9}{3} \pmod{\frac{15}{3}}

    2x≑3(mod5)2x \equiv 3 \pmod 5

    Step 4: Find the unique solution to the reduced congruence.
    We need to find xx such that 2x≑3(mod5)2x \equiv 3 \pmod 5. By inspection or trial and error:
    If x=0x=0, 2(0)=0≑̸3(mod5)2(0)=0 \not\equiv 3 \pmod 5.
    If x=1x=1, 2(1)=2≑̸3(mod5)2(1)=2 \not\equiv 3 \pmod 5.
    If x=2x=2, 2(2)=4≑̸3(mod5)2(2)=4 \not\equiv 3 \pmod 5.
    If x=3x=3, 2(3)=6≑1≑̸3(mod5)2(3)=6 \equiv 1 \not\equiv 3 \pmod 5.
    If x=4x=4, 2(4)=8≑3(mod5)2(4)=8 \equiv 3 \pmod 5.
    So, x0=4x_0 = 4 is the unique solution modulo 55.

    Step 5: Find the dd solutions modulo mm.

    The solutions modulo 1515 are xk=x0+k(md)x_k = x_0 + k \left(\frac{m}{d}\right) for k=0,1,2k=0, 1, 2.
    For k=0k=0:

    x0=4+0β‹…(153)=4(mod15)x_0 = 4 + 0 \cdot \left(\frac{15}{3}\right) = 4 \pmod{15}

    For k=1k=1:
    x1=4+1β‹…(153)=4+5=9(mod15)x_1 = 4 + 1 \cdot \left(\frac{15}{3}\right) = 4+5 = 9 \pmod{15}

    For k=2k=2:
    x2=4+2β‹…(153)=4+10=14(mod15)x_2 = 4 + 2 \cdot \left(\frac{15}{3}\right) = 4+10 = 14 \pmod{15}

    Answer: The solutions are x≑4,9,14(mod15)x \equiv 4, 9, 14 \pmod{15}.

    ---

    5. Modular Exponentiation

    Calculating ak(modm)a^k \pmod m for large kk can be done efficiently using the method of binary exponentiation (also known as exponentiation by squaring).

    πŸ’‘ Binary Exponentiation Algorithm

    To compute ak(modm)a^k \pmod m:

    • Initialize result=1result = 1 and base=a(modm)base = a \pmod m.

    • While k>0k > 0:

    • a. If kk is odd, result=(resultΓ—base)(modm)result = (result \times base) \pmod m.
      b. base=(baseΓ—base)(modm)base = (base \times base) \pmod m.
      c. k=⌊k/2βŒ‹k = \lfloor k/2 \rfloor.
    • Return resultresult.

    This algorithm has a time complexity of O(log⁑k)O(\log k).

    Fermat's Little Theorem:

    πŸ“ Fermat's Little Theorem

    If pp is a prime number, then for any integer aa not divisible by pp:

    apβˆ’1≑1(modp)a^{p-1} \equiv 1 \pmod p

    Also, for any integer aa:
    ap≑a(modp)a^p \equiv a \pmod p

    Variables:

      • aa: Integer

      • pp: Prime number


    When to use: When the modulus is a prime number and the exponent is large, to simplify ak(modp)a^k \pmod p.

    Euler's Totient Theorem:

    πŸ“ Euler's Totient Theorem

    If aa and mm are coprime positive integers (gcd⁑(a,m)=1\gcd(a,m)=1), then:

    aΟ•(m)≑1(modm)a^{\phi(m)} \equiv 1 \pmod m

    where Ο•(m)\phi(m) is Euler's totient function, which counts the number of positive integers less than or equal to mm that are relatively prime to mm.

    Variables:

      • aa: Integer

      • mm: Positive integer modulus

      • Ο•(m)\phi(m): Euler's totient function


    When to use: When the modulus is composite and gcd⁑(a,m)=1\gcd(a,m)=1, to simplify ak(modm)a^k \pmod m.

    Worked Example:

    Problem: Calculate 722(mod11)7^{22} \pmod{11}.

    Solution:

    Step 1: Identify the values and check conditions for Fermat's Little Theorem.

    a=7,k=22,m=11a=7, k=22, m=11
    Since 1111 is a prime number and 77 is not divisible by 1111, we can use Fermat's Little Theorem.

    Step 2: Apply Fermat's Little Theorem.

    711βˆ’1≑710≑1(mod11)7^{11-1} \equiv 7^{10} \equiv 1 \pmod{11}

    Step 3: Rewrite the exponent using the result from Fermat's Little Theorem.

    722=(710)27^{22} = (7^{10})^2

    Step 4: Substitute and calculate modulo 1111.

    722≑(1)2(mod11)7^{22} \equiv (1)^2 \pmod{11}
    722≑1(mod11)7^{22} \equiv 1 \pmod{11}

    Answer: 11

    ---

    6. Pigeonhole Principle (applied to number theory)

    The Pigeonhole Principle (PHP) is a simple yet powerful combinatorial principle often used in number theory proofs, especially in problems involving remainders and divisibility.

    πŸ“– Pigeonhole Principle

    If nn items are put into mm containers, with n>mn > m, then at least one container must contain more than one item.

    In number theory, the "items" are often numbers, and the "containers" are residue classes modulo some integer mm.

    Worked Example:

    Problem: Show that among any set of 66 distinct integers, there must exist 22 integers whose difference is divisible by 55.

    Solution:

    Step 1: Define the "pigeons" and "pigeonholes".

    Pigeons: The 66 distinct integers.
    Pigeonholes: The possible remainders when an integer is divided by 55. These are {0,1,2,3,4}\{0, 1, 2, 3, 4\}. There are 55 pigeonholes.

    Step 2: Apply the Pigeonhole Principle.

    Since there are 66 integers (pigeons) and 55 possible remainders (pigeonholes), by the Pigeonhole Principle, at least two integers must have the same remainder modulo 55.
    Let these two integers be aa and bb.

    Step 3: Conclude based on the definition of congruence.

    If a≑r(mod5)a \equiv r \pmod 5 and b≑r(mod5)b \equiv r \pmod 5 for some remainder rr, then by the properties of congruence:

    aβˆ’b≑rβˆ’r(mod5)a-b \equiv r-r \pmod 5

    aβˆ’b≑0(mod5)a-b \equiv 0 \pmod 5

    This means aβˆ’ba-b is divisible by 55.

    Answer: This demonstrates that among any set of 66 distinct integers, there are always two whose difference is divisible by 55.

    ---

    ---

    7. Applications of Congruences

    Congruence relations have wide-ranging applications in various fields, including:

  • Divisibility Tests: Many common divisibility rules (e.g., by 33, 99, 1111) are based on modular arithmetic.

  • Parity Analysis: Determining whether a number is even or odd is equivalent to working modulo 22. Analyzing numbers modulo 44 is useful for properties of squares.

  • * An even number:
    n≑0(mod2)β€…β€ŠβŸΉβ€…β€Šn2≑0(mod4)n \equiv 0 \pmod 2 \implies n^2 \equiv 0 \pmod 4

    * An odd number:
    n≑1(mod2)β€…β€ŠβŸΉβ€…β€Šn2≑1(mod4)n \equiv 1 \pmod 2 \implies n^2 \equiv 1 \pmod 4

    * An odd number:
    n≑3(mod2)β€…β€ŠβŸΉβ€…β€Šn2≑9≑1(mod4)n \equiv 3 \pmod 2 \implies n^2 \equiv 9 \equiv 1 \pmod 4

    Thus, any square is congruent to 00 or 1(mod4)1 \pmod 4. This is crucial for problems involving sums of squares (like Pythagorean triples).
  • Clock Arithmetic: Time calculations (hours on a clock, days of the week) naturally use modular arithmetic. A 12-hour clock works modulo 1212, and days of the week work modulo 77.

  • * Modeling Clock Hands: The position of clock hands can be represented by angles or units on the clock face. Let tt be time in minutes from 12:00.
    * Minute hand angle:
    ΞΈM(t)=6t(mod360)Β degrees\theta_M(t) = 6t \pmod{360} \text{ degrees}

    * Hour hand angle:
    ΞΈH(t)=t2(mod360)Β degrees\theta_H(t) = \frac{t}{2} \pmod{360} \text{ degrees}

    Problems involving identical clock hands often require finding times t1,t2t_1, t_2 such that the set of angles {ΞΈH(t1),ΞΈM(t1)}\{\theta_H(t_1), \theta_M(t_1)\} is the same as {ΞΈH(t2),ΞΈM(t2)}\{\theta_H(t_2), \theta_M(t_2)\}, where t1β‰ t2t_1 \ne t_2 and the hands are effectively swapped. This leads to solving systems of congruences.

    Worked Example:

    Problem: Determine if a right-angled triangle can have integer side lengths a,b,ca, b, c where both aa and bb are odd.

    Solution:

    Step 1: State the Pythagorean theorem.

    a2+b2=c2a^2 + b^2 = c^2

    Step 2: Analyze the parities of aa and bb.

    Given aa is odd,

    a≑1(mod2)a \equiv 1 \pmod 2

    Given bb is odd,
    b≑1(mod2)b \equiv 1 \pmod 2

    Step 3: Analyze the squares modulo 44.

    If nn is odd, then n=2k+1n = 2k+1 for some integer kk.

    n2=(2k+1)2=4k2+4k+1=4(k2+k)+1n^2 = (2k+1)^2 = 4k^2 + 4k + 1 = 4(k^2+k) + 1

    So, for any odd integer nn,
    n2≑1(mod4)n^2 \equiv 1 \pmod 4

    Step 4: Apply this to a2a^2 and b2b^2.

    Since aa is odd,

    a2≑1(mod4)a^2 \equiv 1 \pmod 4

    Since bb is odd,
    b2≑1(mod4)b^2 \equiv 1 \pmod 4

    Step 5: Calculate a2+b2(mod4)a^2+b^2 \pmod 4.

    a2+b2≑1+1(mod4)a^2+b^2 \equiv 1+1 \pmod 4
    a2+b2≑2(mod4)a^2+b^2 \equiv 2 \pmod 4

    Step 6: Analyze c2(mod4)c^2 \pmod 4.

    From the Pythagorean theorem, c2=a2+b2c^2 = a^2+b^2. So

    c2≑2(mod4)c^2 \equiv 2 \pmod 4

    However, we know that any perfect square n2n^2 must be congruent to 0(mod4)0 \pmod 4 (if nn is even) or 1(mod4)1 \pmod 4 (if nn is odd).
    If nn is even:
    n=2kβ€…β€ŠβŸΉβ€…β€Šn2=4k2≑0(mod4)n=2k \implies n^2 = 4k^2 \equiv 0 \pmod 4

    If nn is odd:
    n=2k+1β€…β€ŠβŸΉβ€…β€Šn2=4k2+4k+1≑1(mod4)n=2k+1 \implies n^2 = 4k^2+4k+1 \equiv 1 \pmod 4

    Thus,
    c2≑̸2(mod4)c^2 \not\equiv 2 \pmod 4

    This is a contradiction.

    Step 7: Conclude.

    Since c2≑2(mod4)c^2 \equiv 2 \pmod 4 is impossible for any integer cc, there are no right-angled triangles with integer side lengths where both aa and bb are odd.

    Answer: \boxed{No such right-angled triangles exist.}

    ---

    Problem-Solving Strategies

    πŸ’‘ CMI Strategy

    • Reduce first, then operate: Before performing arithmetic operations, reduce numbers modulo mm to their smallest non-negative residues (or smallest absolute value residues like βˆ’1,0,1-1, 0, 1). This keeps calculations manageable.

    • Look for patterns: For modular exponentiation, look for cycles in the powers of the base modulo mm. Fermat's Little Theorem or Euler's Totient Theorem are powerful shortcuts.

    • Use definitions: When proving divisibility, convert the statement into a congruence relation:

    • A∣Bβ€…β€ŠβŸΊβ€…β€ŠB≑0(modA)A \mid B \iff B \equiv 0 \pmod A

    • Parity and Modulo 4: For problems involving squares or sums of squares, consider the properties of numbers modulo 22 or modulo 44. n2(mod4)n^2 \pmod 4 is a very common tool (always 00 or 11).

    • Pigeonhole Principle: For problems asking "show that there must exist" or involving a specific number of items that guarantee a property, consider using the Pigeonhole Principle with residue classes as pigeonholes.

    ---

    Common Mistakes

    ⚠️ Avoid These Errors
      • ❌ Incorrect Division: Dividing by cc in ac≑bc(modm)ac \equiv bc \pmod m to get a≑b(modm)a \equiv b \pmod m without checking gcd⁑(c,m)=1\gcd(c,m)=1.
    βœ… Correct Approach: Divide by d=gcd⁑(c,m)d = \gcd(c,m) to get a≑b(modm/d)a \equiv b \pmod{m/d}.
      • ❌ Ignoring Modulo in Exponent: Applying ak≑ak(modΟ•(m))(modm)a^k \equiv a^{k \pmod {\phi(m)}} \pmod m when kk is not reduced modulo Ο•(m)\phi(m) for Euler's Theorem. (The exponent should be reduced modulo Ο•(m)\phi(m) if kβ‰₯Ο•(m)k \ge \phi(m)). For Fermat's Little Theorem, ak≑ak(modpβˆ’1)(modp)a^k \equiv a^{k \pmod{p-1}} \pmod p (if kβ‰₯pβˆ’1k \ge p-1).
    βœ… Correct Approach: Use ak≑ak(modΟ•(m))(modm)a^k \equiv a^{k \pmod{\phi(m)}} \pmod m only if kβ‰₯Ο•(m)k \ge \phi(m) and gcd⁑(a,m)=1\gcd(a,m)=1. If k<Ο•(m)k < \phi(m), use the original exponent. If k=0k=0, a0≑1(modm)a^0 \equiv 1 \pmod m.
      • ❌ Confusing ax≑b(modm)ax \equiv b \pmod m with ax=b+kmax = b + km: While equivalent, solving directly with the congruence notation is often more efficient.
    βœ… Correct Approach: Manipulate congruences directly using their algebraic properties.
      • ❌ Misapplying Pigeonhole Principle: Incorrectly identifying the number of pigeons or pigeonholes, or failing to define what property makes them "share" a hole.
    βœ… Correct Approach: Clearly define pigeons and pigeonholes, then state the property that implies two pigeons are in the same hole (e.g., same remainder modulo mm).

    ---

    Practice Questions

    :::question type="MCQ" question="Let N=72023+32023N = 7^{2023} + 3^{2023}. What is the remainder when NN is divided by 1010?" options=["0","2","4","6"] answer="0" hint="Consider N(mod2)N \pmod 2 and N(mod5)N \pmod 5 separately, then use the Chinese Remainder Theorem concept, or directly calculate N(mod10)N \pmod{10}." solution="Step 1: Calculate 72023(mod10)7^{2023} \pmod{10}.
    The powers of 7(mod10)7 \pmod{10} cycle:
    71≑7(mod10)7^1 \equiv 7 \pmod{10}
    72≑49≑9(mod10)7^2 \equiv 49 \equiv 9 \pmod{10}
    73≑9Γ—7=63≑3(mod10)7^3 \equiv 9 \times 7 = 63 \equiv 3 \pmod{10}
    74≑3Γ—7=21≑1(mod10)7^4 \equiv 3 \times 7 = 21 \equiv 1 \pmod{10}
    The cycle length is 44.
    We need 2023(mod4)2023 \pmod 4. 2023=4Γ—505+32023 = 4 \times 505 + 3.
    So, 72023≑73≑3(mod10)7^{2023} \equiv 7^3 \equiv 3 \pmod{10}.

    Step 2: Calculate 32023(mod10)3^{2023} \pmod{10}.
    The powers of 3(mod10)3 \pmod{10} cycle:
    31≑3(mod10)3^1 \equiv 3 \pmod{10}
    32≑9(mod10)3^2 \equiv 9 \pmod{10}
    33≑9Γ—3=27≑7(mod10)3^3 \equiv 9 \times 3 = 27 \equiv 7 \pmod{10}
    34≑7Γ—3=21≑1(mod10)3^4 \equiv 7 \times 3 = 21 \equiv 1 \pmod{10}
    The cycle length is 44.
    Again, 2023(mod4)=32023 \pmod 4 = 3.
    So, 32023≑33≑7(mod10)3^{2023} \equiv 3^3 \equiv 7 \pmod{10}.

    Step 3: Calculate N(mod10)N \pmod{10}.

    N=72023+32023≑3+7(mod10)N = 7^{2023} + 3^{2023} \equiv 3 + 7 \pmod{10}

    N≑10(mod10)N \equiv 10 \pmod{10}

    N≑0(mod10)N \equiv 0 \pmod{10}

    Answer: \boxed{0}"
    :::

    :::question type="NAT" question="A digital clock displays time in 24-hour format. If the clock is currently displaying 14:3514:35, what time will it display exactly 100100 hours from now? (Provide the answer in HHMM format, e.g., 0530 for 05:30)." answer="1835" hint="Use modular arithmetic for hours. Minutes remain unchanged." solution="Step 1: The current time is 1414 hours and 3535 minutes. We need to find the time 100100 hours from now. The minutes part will not change.
    New hour will be (14+100)(mod24)(14 + 100) \pmod{24}.

    Step 2: Calculate the sum of hours.

    14+100=11414 + 100 = 114

    Step 3: Calculate the result modulo 2424.

    114(mod24)114 \pmod{24}

    We can divide 114114 by 2424:
    114=4Γ—24+18114 = 4 \times 24 + 18
    So, 114≑18(mod24)114 \equiv 18 \pmod{24}.

    Step 4: Combine with the minutes.
    The new time will be 18:3518:35.

    Step 5: Format the answer as HHMM.
    Answer: \boxed{1835}"
    :::

    :::question type="MSQ" question="Which of the following statements are true for integers a,b,ca, b, c and modulus m>1m > 1?" options=["If a≑b(modm)a \equiv b \pmod m, then a+c≑b+c(modm)a+c \equiv b+c \pmod m.","If ac≑bc(modm)ac \equiv bc \pmod m, then a≑b(modm)a \equiv b \pmod m.","If a2≑b2(modm)a^2 \equiv b^2 \pmod m, then a≑b(modm)a \equiv b \pmod m.","If a≑b(modm)a \equiv b \pmod m and c≑d(modm)c \equiv d \pmod m, then ac≑bd(modm)ac \equiv bd \pmod m. "] answer="A,D" hint="Carefully review the properties of congruence, especially division and exponentiation." solution="Option A: If a≑b(modm)a \equiv b \pmod m, then a+c≑b+c(modm)a+c \equiv b+c \pmod m. This is a basic property of congruence (addition). It is true.

    Option B: If ac≑bc(modm)ac \equiv bc \pmod m, then a≑b(modm)a \equiv b \pmod m. This is false. Division in modular arithmetic requires gcd⁑(c,m)=1\gcd(c,m)=1. For example, 2Γ—3≑4Γ—3(mod6)2 \times 3 \equiv 4 \times 3 \pmod 6 (6≑12(mod6)6 \equiv 12 \pmod 6), but 2≑̸4(mod6)2 \not\equiv 4 \pmod 6. The correct statement is a≑b(modm/gcd⁑(c,m))a \equiv b \pmod{m/\gcd(c,m)}.

    Option C: If a2≑b2(modm)a^2 \equiv b^2 \pmod m, then a≑b(modm)a \equiv b \pmod m. This is false. For example, 22≑(βˆ’2)2(mod6)2^2 \equiv (-2)^2 \pmod 6 (4≑4(mod6)4 \equiv 4 \pmod 6), but 2β‰‘ΜΈβˆ’2(mod6)2 \not\equiv -2 \pmod 6 (since 2≑̸4(mod6)2 \not\equiv 4 \pmod 6). Also, 22≑42(mod12)2^2 \equiv 4^2 \pmod{12} (4≑16(mod12)4 \equiv 16 \pmod{12}), but 2≑̸4(mod12)2 \not\equiv 4 \pmod{12}.

    Option D: If a≑b(modm)a \equiv b \pmod m and c≑d(modm)c \equiv d \pmod m, then ac≑bd(modm)ac \equiv bd \pmod m. This is a basic property of congruence (multiplication). It is true.
    Answer: \boxed{A,D}"
    :::

    :::question type="SUB" question="Prove that n5βˆ’nn^5 - n is divisible by 55 for any integer nn." answer="Proof relies on Fermat's Little Theorem or checking cases modulo 5." hint="Consider using Fermat's Little Theorem or checking all possible residues of nn modulo 55." solution="We want to prove that n5βˆ’n≑0(mod5)n^5 - n \equiv 0 \pmod 5 for any integer nn.

    Method 1: Using Fermat's Little Theorem

    Step 1: State Fermat's Little Theorem.
    Fermat's Little Theorem states that if pp is a prime number, then for any integer nn, np≑n(modp)n^p \equiv n \pmod p.
    In this case, p=5p=5.

    Step 2: Apply the theorem.
    According to Fermat's Little Theorem, for p=5p=5, we have:

    n5≑n(mod5)n^5 \equiv n \pmod 5

    Step 3: Rearrange the congruence.
    Subtract nn from both sides:

    n5βˆ’n≑nβˆ’n(mod5)n^5 - n \equiv n - n \pmod 5

    n5βˆ’n≑0(mod5)n^5 - n \equiv 0 \pmod 5

    Step 4: Conclude.
    Since n5βˆ’n≑0(mod5)n^5 - n \equiv 0 \pmod 5, it means n5βˆ’nn^5 - n is divisible by 55 for any integer nn.

    Method 2: Checking all residues modulo 5

    Step 1: Consider all possible residues of nn modulo 55.
    The possible residues are 0,1,2,3,40, 1, 2, 3, 4.

    Step 2: Check each case.
    Case 1: n≑0(mod5)n \equiv 0 \pmod 5

    n5βˆ’n≑05βˆ’0(mod5)n^5 - n \equiv 0^5 - 0 \pmod 5

    n5βˆ’n≑0βˆ’0(mod5)n^5 - n \equiv 0 - 0 \pmod 5

    n5βˆ’n≑0(mod5)n^5 - n \equiv 0 \pmod 5

    Case 2: n≑1(mod5)n \equiv 1 \pmod 5

    n5βˆ’n≑15βˆ’1(mod5)n^5 - n \equiv 1^5 - 1 \pmod 5

    n5βˆ’n≑1βˆ’1(mod5)n^5 - n \equiv 1 - 1 \pmod 5

    n5βˆ’n≑0(mod5)n^5 - n \equiv 0 \pmod 5

    Case 3: n≑2(mod5)n \equiv 2 \pmod 5

    n5βˆ’n≑25βˆ’2(mod5)n^5 - n \equiv 2^5 - 2 \pmod 5

    n5βˆ’n≑32βˆ’2(mod5)n^5 - n \equiv 32 - 2 \pmod 5

    n5βˆ’n≑30(mod5)n^5 - n \equiv 30 \pmod 5

    n5βˆ’n≑0(mod5)n^5 - n \equiv 0 \pmod 5

    Case 4: n≑3(mod5)n \equiv 3 \pmod 5

    n5βˆ’n≑35βˆ’3(mod5)n^5 - n \equiv 3^5 - 3 \pmod 5

    n5βˆ’n≑243βˆ’3(mod5)n^5 - n \equiv 243 - 3 \pmod 5

    n5βˆ’n≑240(mod5)n^5 - n \equiv 240 \pmod 5

    n5βˆ’n≑0(mod5)n^5 - n \equiv 0 \pmod 5

    Case 5: n≑4(mod5)n \equiv 4 \pmod 5

    n5βˆ’n≑45βˆ’4(mod5)n^5 - n \equiv 4^5 - 4 \pmod 5

    n5βˆ’n≑1024βˆ’4(mod5)n^5 - n \equiv 1024 - 4 \pmod 5

    n5βˆ’n≑1020(mod5)n^5 - n \equiv 1020 \pmod 5

    n5βˆ’n≑0(mod5)n^5 - n \equiv 0 \pmod 5

    Step 3: Conclude.
    In all possible cases, n5βˆ’n≑0(mod5)n^5 - n \equiv 0 \pmod 5. Therefore, n5βˆ’nn^5 - n is divisible by 55 for any integer nn.
    Answer: \boxed{Proven}"
    :::

    :::question type="NAT" question="Consider an analogue clock with only an hour hand. If it currently points exactly at 33, and moves continuously, what number will it point to 10001000 hours later? (Assume a 12-hour cycle for the clock face. Provide the answer as a plain number from 1 to 12)." answer="11" hint="Use modular arithmetic for hours, adjusting for the 1-12 range." solution="Step 1: The clock is a 12-hour clock. We are interested in the hour hand's position modulo 12.
    Current position: 33.

    Step 2: Calculate the total hours passed.
    Total hours = 10001000.

    Step 3: Find the position modulo 1212.
    The new position will be (3+1000)(mod12)(3 + 1000) \pmod{12}.

    Step 4: Perform the addition.

    3+1000=10033 + 1000 = 1003

    Step 5: Calculate the remainder modulo 1212.

    1003(mod12)1003 \pmod{12}

    Divide 10031003 by 1212:
    1003=12Γ—83+71003 = 12 \times 83 + 7
    So, 1003≑7(mod12)1003 \equiv 7 \pmod{12}.

    Step 6: Interpret the result for a 12-hour clock.
    A remainder of 00 usually corresponds to 1212 on a clock face. For remainders 11 through 1111, they correspond directly to the numbers 11 through 1111.
    Since the remainder is 77, the hour hand will point to 77.
    Answer: \boxed{11}"
    :::

    ---

    πŸ’‘ Moving Forward

    Now that you understand Congruence Relations, let's explore Operations in Modular Arithmetic which builds on these concepts.

    ---

    Part 2: Operations in Modular Arithmetic

    Introduction

    Modular arithmetic is a fundamental branch of number theory that deals with integers and their remainders when divided by a fixed positive integer, known as the modulus. It provides a powerful framework for analyzing properties of numbers and has widespread applications in Data Science, including cryptography (e.g., RSA algorithm relies heavily on modular exponentiation), hashing functions, error detection and correction codes, and pseudo-random number generation. For the CMI exam, understanding operations within modular arithmetic is crucial for solving problems involving number theory, discrete mathematics, and algorithmic analysis. This section will cover the core definitions, properties, and applications of modular arithmetic, including number representation in different bases and polynomial congruences.

    πŸ“– Congruence Modulo n

    Two integers aa and bb are said to be congruent modulo nn if their difference aβˆ’ba-b is an integer multiple of nn. This is denoted by:

    a≑b(modn)a \equiv b \pmod n

    Equivalently, aa and bb have the same remainder when divided by nn. That is, if a=q1n+ra = q_1 n + r and b=q2n+rb = q_2 n + r for some integers q1,q2q_1, q_2 and 0≀r<n0 \le r < n, then a≑b(modn)a \equiv b \pmod n.

    ---

    ---

    Key Concepts

    1. Basic Properties of Congruence

    Modular congruence is an equivalence relation and possesses several key properties that simplify arithmetic operations.

    πŸ“ Properties of Congruence

    If a,b,c,da, b, c, d are integers and nn is a positive integer:

    Reflexive Property:

    a≑a(modn)a \equiv a \pmod n

    Symmetric Property:

    a≑b(modn)β€…β€ŠβŸΉβ€…β€Šb≑a(modn)a \equiv b \pmod n \implies b \equiv a \pmod n

    Transitive Property:

    a≑b(modn)Β andΒ b≑c(modn)β€…β€ŠβŸΉβ€…β€Ša≑c(modn)a \equiv b \pmod n \text{ and } b \equiv c \pmod n \implies a \equiv c \pmod n

    Addition/Subtraction Property:
    If a≑b(modn)a \equiv b \pmod n and c≑d(modn)c \equiv d \pmod n, then:

    a+c≑b+d(modn)a+c \equiv b+d \pmod n

    aβˆ’c≑bβˆ’d(modn)a-c \equiv b-d \pmod n

    Multiplication Property:
    If a≑b(modn)a \equiv b \pmod n and c≑d(modn)c \equiv d \pmod n, then:

    ac≑bd(modn)ac \equiv bd \pmod n

    Exponentiation Property:
    If a≑b(modn)a \equiv b \pmod n, then for any non-negative integer kk:

    ak≑bk(modn)a^k \equiv b^k \pmod n

    Cancellation Property (with caveats):
    If ac≑bc(modn)ac \equiv bc \pmod n, then a≑b(modngcd⁑(c,n))a \equiv b \pmod{\frac{n}{\gcd(c,n)}}.
    If gcd⁑(c,n)=1\gcd(c,n) = 1, then ac≑bc(modn)β€…β€ŠβŸΉβ€…β€Ša≑b(modn)ac \equiv bc \pmod n \implies a \equiv b \pmod n.

    Worked Example: Applying Basic Properties

    Problem: Find the remainder when 1310013^{100} is divided by 77.

    Solution:

    Step 1: Simplify the base modulo 77.

    13≑6(mod7)13 \equiv 6 \pmod 7
    Also, 6β‰‘βˆ’1(mod7)6 \equiv -1 \pmod 7.

    Step 2: Apply the exponentiation property.

    13100≑6100(mod7)13^{100} \equiv 6^{100} \pmod 7
    13100≑(βˆ’1)100(mod7)13^{100} \equiv (-1)^{100} \pmod 7

    Step 3: Evaluate the power.

    (βˆ’1)100=1(-1)^{100} = 1

    Step 4: State the final congruence.

    13100≑1(mod7)13^{100} \equiv 1 \pmod 7

    Answer: The remainder is 11.

    ---

    2. Polynomial Congruences

    An important property in modular arithmetic is how polynomials behave under congruence. This is directly tested in CMI.

    ❗ Polynomial Congruence Property

    Let p(x)p(x) be a polynomial with integer coefficients, i.e., p(x)=cmxm+cmβˆ’1xmβˆ’1+β‹―+c1x+c0p(x) = c_m x^m + c_{m-1} x^{m-1} + \dots + c_1 x + c_0, where ci∈Zc_i \in \mathbb{Z}.
    If aa and bb are integers such that a≑b(modn)a \equiv b \pmod n, then it is true that p(a)≑p(b)(modn)p(a) \equiv p(b) \pmod n.

    Proof:

    Step 1: Given the congruence a≑b(modn)a \equiv b \pmod n.

    Step 2: Apply the exponentiation property for each term xkx^k.
    Since a≑b(modn)a \equiv b \pmod n, we have ak≑bk(modn)a^k \equiv b^k \pmod n for any non-negative integer kk.

    Step 3: Apply the multiplication property for each coefficient ckc_k.
    Since ck≑ck(modn)c_k \equiv c_k \pmod n and ak≑bk(modn)a^k \equiv b^k \pmod n, we can multiply these congruences:

    ckak≑ckbk(modn)c_k a^k \equiv c_k b^k \pmod n

    Step 4: Apply the addition property for all terms in the polynomial.
    Summing up the congruences for each term from k=0k=0 to mm:

    cmam+cmβˆ’1amβˆ’1+β‹―+c1a+c0≑cmbm+cmβˆ’1bmβˆ’1+β‹―+c1b+c0(modn)c_m a^m + c_{m-1} a^{m-1} + \dots + c_1 a + c_0 \equiv c_m b^m + c_{m-1} b^{m-1} + \dots + c_1 b + c_0 \pmod n

    Step 5: Conclude the result.
    The left side is p(a)p(a) and the right side is p(b)p(b).
    Therefore, p(a)≑p(b)(modn)p(a) \equiv p(b) \pmod n.

    Worked Example:

    Problem: Let p(x)=3x3βˆ’2x+5p(x) = 3x^3 - 2x + 5. If a≑4(mod5)a \equiv 4 \pmod 5, show that p(a)≑p(4)(mod5)p(a) \equiv p(4) \pmod 5.

    Solution:

    Step 1: Use the given congruence a≑4(mod5)a \equiv 4 \pmod 5.

    Step 2: Apply the polynomial congruence property.
    Since p(x)p(x) is a polynomial with integer coefficients and a≑4(mod5)a \equiv 4 \pmod 5, we directly apply the property that p(a)≑p(4)(mod5)p(a) \equiv p(4) \pmod 5.

    Step 3: Calculate p(4)(mod5)p(4) \pmod 5.

    p(4)=3(4)3βˆ’2(4)+5p(4) = 3(4)^3 - 2(4) + 5
    p(4)=3(64)βˆ’8+5p(4) = 3(64) - 8 + 5
    p(4)=192βˆ’8+5p(4) = 192 - 8 + 5
    p(4)=189p(4) = 189

    Step 4: Find the remainder of p(4)p(4) when divided by 55.

    189=37Γ—5+4189 = 37 \times 5 + 4
    So, 189≑4(mod5)189 \equiv 4 \pmod 5.

    Step 5: Conclude.
    Thus, p(a)≑4(mod5)p(a) \equiv 4 \pmod 5. This demonstrates that p(a)≑p(4)(mod5)p(a) \equiv p(4) \pmod 5.

    Answer: p(a)≑p(4)(mod5)p(a) \equiv p(4) \pmod 5.

    ---

    3. Number Representation in Different Bases

    Numbers can be represented in various bases (radix systems), not just base 10 (decimal). A number in base kk is represented by a sequence of digits (ntntβˆ’1…n1n0)k(n_t n_{t-1} \dots n_1 n_0)_k, where each digit nin_i satisfies 0≀ni<k0 \le n_i < k.

    πŸ“– Base k Representation

    An integer NN can be uniquely represented in base kk (where kk is an integer greater than 11) as:

    N=ntkt+ntβˆ’1ktβˆ’1+β‹―+n1k1+n0k0N = n_t k^t + n_{t-1} k^{t-1} + \dots + n_1 k^1 + n_0 k^0

    where nin_i are the digits, 0≀ni<k0 \le n_i < k for all ii, and ntβ‰ 0n_t \ne 0 if N>0N > 0. This is denoted as (ntntβˆ’1…n0)k(n_t n_{t-1} \dots n_0)_k.

    #### 3.1. Converting from Base kk to Base 10

    To convert a number (ntntβˆ’1…n0)k(n_t n_{t-1} \dots n_0)_k to its base 10 equivalent, simply evaluate the polynomial expression:

    N10=ntkt+ntβˆ’1ktβˆ’1+β‹―+n1k1+n0k0N_{10} = n_t k^t + n_{t-1} k^{t-1} + \dots + n_1 k^1 + n_0 k^0

    Worked Example:

    Problem: Convert (312)4(312)_4 to base 10.

    Solution:

    Step 1: Write out the positional value expression.

    (312)4=3Γ—42+1Γ—41+2Γ—40(312)_4 = 3 \times 4^2 + 1 \times 4^1 + 2 \times 4^0

    Step 2: Calculate each term.

    3Γ—16+1Γ—4+2Γ—13 \times 16 + 1 \times 4 + 2 \times 1
    48+4+248 + 4 + 2

    Step 3: Sum the terms.

    5454

    Answer: (312)4=5410(312)_4 = 54_{10}.

    #### 3.2. Converting from Base 10 to Base kk

    To convert a base 10 number N10N_{10} to base kk, use the repeated division algorithm:

  • Divide N10N_{10} by kk. The remainder is the last digit (n0n_0).

  • Take the quotient from step 1 and divide it by kk. The remainder is the next digit (n1n_1).

  • Repeat until the quotient is 00. The digits are read in reverse order of their calculation.
  • Worked Example:

    Problem: Convert 751075_{10} to base 5.

    Solution:

    Step 1: Divide 7575 by 55.

    75Γ·5=15Β remainderΒ 0(n0)75 \div 5 = 15 \text{ remainder } 0 \quad (n_0)

    Step 2: Divide the quotient 1515 by 55.

    15Γ·5=3Β remainderΒ 0(n1)15 \div 5 = 3 \text{ remainder } 0 \quad (n_1)

    Step 3: Divide the quotient 33 by 55.

    3Γ·5=0Β remainderΒ 3(n2)3 \div 5 = 0 \text{ remainder } 3 \quad (n_2)

    Step 4: Read the remainders from bottom to top.

    (300)5(300)_5

    Answer: 7510=(300)575_{10} = (300)_5.

    #### 3.3. Converting Between Arbitrary Bases

    To convert a number from base k1k_1 to base k2k_2:

  • Convert the number from base k1k_1 to base 10.

  • Convert the resulting base 10 number to base k2k_2.
  • Special Case: Bases that are Powers of Each Other
    If k2=k1mk_2 = k_1^m (e.g., base 2 to base 8, where 8=238 = 2^3), you can group digits.
    To convert from base k1k_1 to base k1mk_1^m:

  • Group mm digits of the base k1k_1 number, starting from the right. Pad with leading zeros if necessary.

  • Convert each group of mm digits into a single digit in base k1mk_1^m.
  • Worked Example:

    Problem: Convert (1101101)2(1101101)_2 to base 8.

    Solution:

    Step 1: Group the binary digits into sets of three from the right (since 8=238 = 2^3). Pad with leading zeros if needed.

    (001Β 101Β 101)2(001\ 101\ 101)_2

    Step 2: Convert each group of three binary digits to its decimal equivalent (which will be the base 8 digit).

    0012=110001_2 = 1_{10}
    1012=510101_2 = 5_{10}
    1012=510101_2 = 5_{10}

    Step 3: Combine the base 8 digits.

    (155)8(155)_8

    Answer: (1101101)2=(155)8(1101101)_2 = (155)_8.

    ---

    ---

    #
    ## 4. Modular Multiplicative Inverse

    The concept of division in modular arithmetic is handled using the multiplicative inverse.

    πŸ“– Modular Multiplicative Inverse

    An integer xx is a modular multiplicative inverse of aa modulo nn if ax≑1(modn)ax \equiv 1 \pmod n.
    The inverse exists if and only if gcd⁑(a,n)=1\gcd(a, n) = 1.
    If it exists, the inverse is unique modulo nn.

    Finding the Inverse:

    * Extended Euclidean Algorithm: For general aa and nn where gcd⁑(a,n)=1\gcd(a, n) = 1, this algorithm can find integers xx and yy such that ax+ny=gcd⁑(a,n)=1ax + ny = \gcd(a, n) = 1. Taking this equation modulo nn, we get ax≑1(modn)ax \equiv 1 \pmod n, so xx is the inverse.
    * Fermat's Little Theorem: If nn is a prime number, then for any integer aa not divisible by nn, we have anβˆ’1≑1(modn)a^{n-1} \equiv 1 \pmod n. This implies anβˆ’2a^{n-2} is the inverse of aa modulo nn.

    Worked Example:

    Problem: Find the modular multiplicative inverse of 55 modulo 1313.

    Solution:

    Step 1: Check if an inverse exists.
    gcd⁑(5,13)=1\gcd(5, 13) = 1, so an inverse exists.

    Step 2: Use the Extended Euclidean Algorithm or trial and error for small numbers.
    We want to find xx such that 5x≑1(mod13)5x \equiv 1 \pmod{13}.
    This means 5x=13k+15x = 13k + 1 for some integer kk.
    Let's test values for xx:
    If x=1x=1, 5Γ—1=5≑̸1(mod13)5 \times 1 = 5 \not\equiv 1 \pmod{13}
    If x=2x=2, 5Γ—2=10≑̸1(mod13)5 \times 2 = 10 \not\equiv 1 \pmod{13}
    If x=3x=3, 5Γ—3=15≑2(mod13)5 \times 3 = 15 \equiv 2 \pmod{13}
    If x=4x=4, 5Γ—4=20≑7(mod13)5 \times 4 = 20 \equiv 7 \pmod{13}
    If x=5x=5, 5Γ—5=25≑12(mod13)5 \times 5 = 25 \equiv 12 \pmod{13}
    If x=6x=6, 5Γ—6=30≑4(mod13)5 \times 6 = 30 \equiv 4 \pmod{13}
    If x=7x=7, 5Γ—7=35≑9(mod13)5 \times 7 = 35 \equiv 9 \pmod{13}
    If x=8x=8, 5Γ—8=40≑1(mod13)5 \times 8 = 40 \equiv 1 \pmod{13}

    Step 3: Identify the inverse.
    The inverse is 88.

    Answer: The modular multiplicative inverse of 55 modulo 1313 is 88.

    ---

    #
    ## 5. Applications: Parity and Modulo 2 Arithmetic

    Many problems, especially those involving "on/off" states, toggling, or counts of even/odd items, can be modeled using modular arithmetic modulo 2.
    In modulo 2 arithmetic:
    * 00 represents "off" or "even".
    * 11 represents "on" or "odd".
    * Addition is equivalent to XOR.
    * 0+0≑0(mod2)0+0 \equiv 0 \pmod 2
    * 0+1≑1(mod2)0+1 \equiv 1 \pmod 2
    * 1+0≑1(mod2)1+0 \equiv 1 \pmod 2
    * 1+1≑0(mod2)1+1 \equiv 0 \pmod 2
    * Toggling a switch means changing its state ss to s+1(mod2)s+1 \pmod 2.

    A common strategy is to look for invariants modulo 2. For example, if an operation always changes the state of an even number of items, then the parity of the total number of "on" items remains invariant.

    Worked Example:

    Problem: You have a row of 5 lights, initially (off, on, off, on, off). In one move, you can pick any two adjacent lights and toggle both of them. Is it possible to turn all 5 lights on?

    Solution:

    Step 1: Represent the states as numbers modulo 2.
    Let si∈{0,1}s_i \in \{0, 1\} be the state of light ii (0 for off, 1 for on).
    Initial state: (s1,s2,s3,s4,s5)=(0,1,0,1,0)(s_1, s_2, s_3, s_4, s_5) = (0, 1, 0, 1, 0).
    Target state: (1,1,1,1,1)(1, 1, 1, 1, 1).

    Step 2: Analyze the effect of the operation on the sum of states modulo 2.
    Let S=βˆ‘i=15si(mod2)S = \sum_{i=1}^5 s_i \pmod 2.
    Initial sum: 0+1+0+1+0=2≑0(mod2)0+1+0+1+0 = 2 \equiv 0 \pmod 2.
    Target sum: 1+1+1+1+1=5≑1(mod2)1+1+1+1+1 = 5 \equiv 1 \pmod 2.

    Step 3: Consider the effect of toggling two adjacent lights.
    If we pick lights ii and i+1i+1, their states change from (si,si+1)(s_i, s_{i+1}) to (si+1(mod2),si+1+1(mod2))(s_i+1 \pmod 2, s_{i+1}+1 \pmod 2).
    The change in the sum of states is (si+1+si+1+1)βˆ’(si+si+1)=2≑0(mod2)(s_i+1 + s_{i+1}+1) - (s_i+s_{i+1}) = 2 \equiv 0 \pmod 2.
    This means that each move changes the sum of the states by 0(mod2)0 \pmod 2. The parity of the total number of "on" lights is an invariant.

    Step 4: Compare the parity of the initial and target states.
    Initial state sum parity: 0(mod2)0 \pmod 2 (even number of "on" lights).
    Target state sum parity: 1(mod2)1 \pmod 2 (odd number of "on" lights).

    Since the parity of the sum of "on" lights is invariant under the allowed operation, and the initial state has an even sum while the target state has an odd sum, it is impossible to reach the target state.

    Answer: No, it is not possible to turn all 5 lights on.

    ---

    Problem-Solving Strategies

    πŸ’‘ CMI Strategy

    • Simplify First: Always reduce numbers modulo nn before performing operations (especially for large numbers or exponents). For example, aΓ—b(modn)a \times b \pmod n is easier as (a(modn)Γ—b(modn))(modn)(a \pmod n \times b \pmod n) \pmod n.

    • Look for Invariants: In problems involving state changes or sequences of operations (like the switch problem), identify quantities that remain constant modulo nn (often modulo 2 for parity).

    • Use Negative Remainders: Sometimes using negative remainders can simplify calculations, e.g., 6β‰‘βˆ’1(mod7)6 \equiv -1 \pmod 7.

    • Base Conversion as a Tool: Remember the two-step process for converting between arbitrary bases (via base 10). For bases that are powers of each other (e.g., binary to octal/hexadecimal), use the grouping method for speed.

    • Polynomial Congruence: If a≑b(modn)a \equiv b \pmod n, then p(a)≑p(b)(modn)p(a) \equiv p(b) \pmod n is a powerful direct result; no need to calculate p(a)p(a) and p(b)p(b) explicitly if aa and bb are large.

    ---

    Common Mistakes

    ⚠️ Avoid These Errors
      • ❌ Incorrect Division: ac≑bc(modn)ac \equiv bc \pmod n does NOT generally imply a≑b(modn)a \equiv b \pmod n.
    βœ… Correct Approach: You can only "cancel" cc if gcd⁑(c,n)=1\gcd(c,n)=1. Otherwise, ac≑bc(modn)β€…β€ŠβŸΉβ€…β€Ša≑b(modn/gcd⁑(c,n))ac \equiv bc \pmod n \implies a \equiv b \pmod{n/\gcd(c,n)}.
      • ❌ Forgetting Modulo in Intermediate Steps: Performing calculations and only taking the modulo at the very end can lead to extremely large numbers, making computation difficult or impossible.
    βœ… Correct Approach: Apply the modulo operator at each step where possible to keep numbers small, especially in exponentiation.
      • ❌ Base Conversion Errors: Mixing up the order of digits or miscalculating powers of the base.
    βœ… Correct Approach: For base kk to base 10, ensure correct powers of kk are assigned to each digit. For base 10 to base kk, ensure remainders are collected in the correct (reverse) order.
      • ❌ Misunderstanding Modulo 2: Confusing parity of individual elements with parity of a sum or count.
    βœ… Correct Approach: Clearly define what 00 and 11 represent in the context of the problem and analyze how operations affect the sum modulo 2.

    ---

    Practice Questions

    :::question type="NAT" question="Convert the base 7 number (253)7(253)_7 to base 4. Express your answer as a plain number string (e.g., 123)." answer="2020" hint="First convert to base 10, then to base 4." solution="Step 1: Convert (253)7(253)_7 to base 10.

    (253)7=2Γ—72+5Γ—71+3Γ—70(253)_7 = 2 \times 7^2 + 5 \times 7^1 + 3 \times 7^0

    =2Γ—49+5Γ—7+3Γ—1= 2 \times 49 + 5 \times 7 + 3 \times 1

    =98+35+3=13610= 98 + 35 + 3 = 136_{10}

    Step 2: Convert 13610136_{10} to base 4 using repeated division.

    136Γ·4=34Β remainderΒ 0136 \div 4 = 34 \text{ remainder } 0

    34Γ·4=8Β remainderΒ 234 \div 4 = 8 \text{ remainder } 2

    8Γ·4=2Β remainderΒ 08 \div 4 = 2 \text{ remainder } 0

    2Γ·4=0Β remainderΒ 22 \div 4 = 0 \text{ remainder } 2

    Reading the remainders from bottom to top gives (2020)4(2020)_4.

    Answer: 2020\boxed{2020}
    "
    :::

    :::question type="SUB" question="Prove that for any integer xx, x5≑x(mod10)x^5 \equiv x \pmod{10}." answer="Proof involves Fermat's Little Theorem and Chinese Remainder Theorem, or direct checking." hint="Consider modulo 2 and modulo 5 separately, then combine." solution="We need to prove x5≑x(mod10)x^5 \equiv x \pmod{10}. This is equivalent to proving:

  • x5≑x(mod2)x^5 \equiv x \pmod{2}

  • x5≑x(mod5)x^5 \equiv x \pmod{5}
  • Part 1: Proving x5≑x(mod2)x^5 \equiv x \pmod{2}
    If xx is even, then x≑0(mod2)x \equiv 0 \pmod{2}.
    Then:

    x5≑05(mod2)x^5 \equiv 0^5 \pmod{2}

    x5≑0(mod2)x^5 \equiv 0 \pmod{2}

    Since x≑0(mod2)x \equiv 0 \pmod{2}, we have x5≑x(mod2)x^5 \equiv x \pmod{2}.
    If xx is odd, then x≑1(mod2)x \equiv 1 \pmod{2}.
    Then:
    x5≑15(mod2)x^5 \equiv 1^5 \pmod{2}

    x5≑1(mod2)x^5 \equiv 1 \pmod{2}

    Since x≑1(mod2)x \equiv 1 \pmod{2}, we have x5≑x(mod2)x^5 \equiv x \pmod{2}.
    In both cases, x5≑x(mod2)x^5 \equiv x \pmod{2} holds.

    Part 2: Proving x5≑x(mod5)x^5 \equiv x \pmod{5}
    By Fermat's Little Theorem, for a prime pp and any integer aa, ap≑a(modp)a^p \equiv a \pmod p.
    Here, p=5p=5. So, x5≑x(mod5)x^5 \equiv x \pmod{5} holds directly from Fermat's Little Theorem.

    Part 3: Combining the results using the Chinese Remainder Theorem principle
    We have:

    x5≑x(mod2)x^5 \equiv x \pmod{2}

    x5≑x(mod5)x^5 \equiv x \pmod{5}

    Since gcd⁑(2,5)=1\gcd(2, 5) = 1, if A≑B(mod2)A \equiv B \pmod{2} and A≑B(mod5)A \equiv B \pmod{5}, then A≑B(mod2Γ—5)A \equiv B \pmod{2 \times 5}.
    Therefore, x5≑x(mod10)x^5 \equiv x \pmod{10}.
    "
    :::

    :::question type="MCQ" question="Which of the following is the modular multiplicative inverse of 77 modulo 1515?" options=["A) 1","B) 4","C) 7","D) 13"] answer="D) 13" hint="We are looking for an integer xx such that 7x≑1(mod15)7x \equiv 1 \pmod{15}." solution="We need to find xx such that 7x≑1(mod15)7x \equiv 1 \pmod{15}.
    Let's test the options:
    A) If x=1x=1,

    7Γ—1=7≑̸1(mod15)7 \times 1 = 7 \not\equiv 1 \pmod{15}

    (Incorrect)

    B) If x=4x=4,

    7Γ—4=287 \times 4 = 28

    28=1Γ—15+13β€…β€ŠβŸΉβ€…β€Š28≑13(mod15)28 = 1 \times 15 + 13 \implies 28 \equiv 13 \pmod{15}

    (Incorrect)

    C) If x=7x=7,

    7Γ—7=497 \times 7 = 49

    49=3Γ—15+4β€…β€ŠβŸΉβ€…β€Š49≑4(mod15)49 = 3 \times 15 + 4 \implies 49 \equiv 4 \pmod{15}

    (Incorrect)

    D) If x=13x=13,

    7Γ—13=917 \times 13 = 91

    91=6Γ—15+1β€…β€ŠβŸΉβ€…β€Š91≑1(mod15)91 = 6 \times 15 + 1 \implies 91 \equiv 1 \pmod{15}

    (Correct)
    Therefore, 1313 is the modular multiplicative inverse of 77 modulo 1515.

    Answer: D\boxed{D}
    "
    :::

    :::question type="MSQ" question="Let M=(11011)2M = (11011)_2. Which of the following statements are true?" options=["A) (M)10=27(M)_{10} = 27","B) M≑3(mod4)M \equiv 3 \pmod 4","C) (M)8=(33)8(M)_8 = (33)_8","D) MM is a prime number."] answer="A,B,C" hint="Convert to base 10 first, then evaluate each condition." solution="Step 1: Convert M=(11011)2M = (11011)_2 to base 10.

    M=1Γ—24+1Γ—23+0Γ—22+1Γ—21+1Γ—20M = 1 \times 2^4 + 1 \times 2^3 + 0 \times 2^2 + 1 \times 2^1 + 1 \times 2^0

    M=16+8+0+2+1M = 16 + 8 + 0 + 2 + 1

    M=2710M = 27_{10}

    So, option A is true.

    Step 2: Check M≑3(mod4)M \equiv 3 \pmod 4 (Option B).

    27Γ·4=6Β remainderΒ 327 \div 4 = 6 \text{ remainder } 3

    So 27≑3(mod4)27 \equiv 3 \pmod 4. Thus, option B is true.

    Step 3: Check (M)8=(33)8(M)_8 = (33)_8 (Option C).
    To convert (11011)2(11011)_2 to base 8, group digits in threes from the right. We can pad with a leading zero:

    (011Β 011)2(011\ 011)_2

    0112=310011_2 = 3_{10}

    0112=310011_2 = 3_{10}

    So, (11011)2=(33)8(11011)_2 = (33)_8. Thus, option C is true.

    Step 4: Check if MM is a prime number (Option D).
    M=27M = 27. Since 27=3327 = 3^3, 2727 is not a prime number (it is a composite number).
    Thus, option D is false.

    Answer: A,B,C\boxed{A,B,C}
    "
    :::

    :::question type="NAT" question="A sequence of operations is defined on a set of three binary variables (x1,x2,x3)(x_1, x_2, x_3), where each xi∈{0,1}x_i \in \{0, 1\}. An operation consists of selecting two variables and flipping their values (i.e., 0β†’10 \to 1 and 1β†’01 \to 0). If the initial state is (0,1,0)(0, 1, 0) and the target state is (1,1,1)(1, 1, 1), what is the parity (0 for even, 1 for odd) of the minimum number of operations required to reach the target state?" answer="1" hint="Consider the sum of the variables modulo 2." solution="Let the state of the variables be represented by xi∈{0,1}x_i \in \{0, 1\}.
    An operation consists of picking two variables, say xix_i and xjx_j, and flipping them. This means xi→xi+1(mod2)x_i \to x_i+1 \pmod{2} and xj→xj+1(mod2)x_j \to x_j+1 \pmod{2}.

    Consider the sum of the variables modulo 2: S=(x1+x2+x3)(mod2)S = (x_1 + x_2 + x_3) \pmod{2}.
    Initial state: (0,1,0)(0, 1, 0). Initial sum:

    Sinitial=(0+1+0)(mod2)=1(mod2)S_{\text{initial}} = (0+1+0) \pmod{2} = 1 \pmod{2}

    Target state: (1,1,1)(1, 1, 1). Target sum:
    Starget=(1+1+1)(mod2)=3(mod2)=1(mod2)S_{\text{target}} = (1+1+1) \pmod{2} = 3 \pmod{2} = 1 \pmod{2}

    When an operation is performed, two variables xix_i and xjx_j are flipped.
    The change in the sum is:

    (xi+1+xj+1)βˆ’(xi+xj)=2≑0(mod2)(x_i+1 + x_j+1) - (x_i+x_j) = 2 \equiv 0 \pmod{2}

    This means that each operation changes the sum of the variables by 0(mod2)0 \pmod{2}.
    Therefore, the sum of the variables modulo 2 is an invariant.
    Since Sinitial=1(mod2)S_{\text{initial}} = 1 \pmod{2} and Starget=1(mod2)S_{\text{target}} = 1 \pmod{2}, it is possible to reach the target state.

    Now, we need to find the minimum number of operations.
    Initial state: (0,1,0)(0,1,0). Target state: (1,1,1)(1,1,1).
    Variables that need to be flipped: x1x_1 (from 00 to 11) and x3x_3 (from 00 to 11). Variable x2x_2 stays 11.
    An operation flips two variables. We need to flip x1x_1 and x3x_3.
    Operation 1: Flip x1x_1 and x3x_3.

    (0,1,0)β†’FlipΒ x1,x3(0+1,1,0+1)=(1,1,1)(0,1,0) \xrightarrow{\text{Flip } x_1, x_3} (0+1, 1, 0+1) = (1,1,1)

    This takes exactly one operation.

    The minimum number of operations is 11.
    The parity of the minimum number of operations is 1(mod2)=11 \pmod{2} = 1.

    Answer: 1\boxed{1}
    "
    :::

    :::question type="SUB" question="Let nn be a positive integer. Prove that n2≑n(mod2)n^2 \equiv n \pmod 2 for all integers nn." answer="Proof by cases: nn is even or nn is odd." hint="Consider n(mod2)n \pmod 2." solution="We need to prove n2≑n(mod2)n^2 \equiv n \pmod{2}.

    Case 1: nn is an even integer.
    If nn is even, then n≑0(mod2)n \equiv 0 \pmod{2}.
    Then:

    n2≑02(mod2)n^2 \equiv 0^2 \pmod{2}

    n2≑0(mod2)n^2 \equiv 0 \pmod{2}

    Since n≑0(mod2)n \equiv 0 \pmod{2}, we have n2≑n(mod2)n^2 \equiv n \pmod{2} in this case.

    Case 2: nn is an odd integer.
    If nn is odd, then n≑1(mod2)n \equiv 1 \pmod{2}.
    Then:

    n2≑12(mod2)n^2 \equiv 1^2 \pmod{2}

    n2≑1(mod2)n^2 \equiv 1 \pmod{2}

    Since n≑1(mod2)n \equiv 1 \pmod{2}, we have n2≑n(mod2)n^2 \equiv n \pmod{2} in this case.

    In both cases, n2≑n(mod2)n^2 \equiv n \pmod{2}.
    Therefore, n2≑n(mod2)n^2 \equiv n \pmod{2} for all integers nn.
    "
    :::

    ---

    Summary

    ❗ Key Takeaways for CMI

    • Congruence Definition: a≑b(modn)a \equiv b \pmod n means n∣(aβˆ’b)n | (a-b) or aa and bb have the same remainder when divided by nn.

    • Properties are Key: Mastering the addition, subtraction, multiplication, and exponentiation properties of congruences is vital for simplifying expressions.

    • Polynomial Congruence: If a≑b(modn)a \equiv b \pmod n, then p(a)≑p(b)(modn)p(a) \equiv p(b) \pmod n for any polynomial p(x)p(x) with integer coefficients. This is a frequently tested concept.

    • Base Conversion: Be proficient in converting between any base kk and base 10, and understand the grouping method for bases that are powers of each other (e.g., binary to octal/hexadecimal).

    • Modular Inverses: Understand when a modular multiplicative inverse exists (gcd⁑(a,n)=1\gcd(a,n)=1) and how to find it (Extended Euclidean Algorithm or Fermat's Little Theorem for prime moduli).

    • Modulo 2 Applications: Parity problems are often solved by analyzing invariants or changes modulo 2.

    ---

    What's Next?

    πŸ’‘ Continue Learning

    This topic connects to:

      • Linear Congruences and Systems of Congruences: Solving equations of the form ax≑b(modn)ax \equiv b \pmod n and systems like those addressed by the Chinese Remainder Theorem. These are crucial for cryptographic algorithms.

      • Number Theoretic Functions: Euler's totient function (Ο•(n)\phi(n)) and its relation to modular exponentiation (Euler's Theorem), which generalizes Fermat's Little Theorem.

      • Cryptography (RSA): The RSA algorithm heavily relies on modular exponentiation, modular inverses, and properties of prime numbers and Euler's totient function.

      • Hashing and Error Correction Codes: Modular arithmetic is used to distribute data across hash tables and to detect/correct errors in data transmission.


    Master these connections for comprehensive CMI preparation!

    ---

    Chapter Summary

    πŸ“– Modular Arithmetic - Key Takeaways

    Here are the most important concepts from Modular Arithmetic that you must master for CMI:

    • Definition of Congruence: Understand a≑b(modn)β€…β€ŠβŸΊβ€…β€Šn∣(aβˆ’b)a \equiv b \pmod n \iff n | (a-b). This means aa and bb have the same remainder when divided by nn. This equivalence relation partitions integers into nn distinct congruence classes.

    • Arithmetic Operations: Congruences can be added, subtracted, and multiplied:

    • If a≑b(modn)a \equiv b \pmod n and c≑d(modn)c \equiv d \pmod n, then aΒ±c≑bΒ±d(modn)a \pm c \equiv b \pm d \pmod n and ac≑bd(modn)ac \equiv bd \pmod n. Division is not always straightforward.
    • Modular Inverse: An integer aa has a multiplicative inverse modulo nn, denoted aβˆ’1a^{-1}, if and only if gcd⁑(a,n)=1\gcd(a,n)=1. If it exists, it is unique modulo nn. The Extended Euclidean Algorithm is the primary method to find aβˆ’1a^{-1}.

    • Solving Linear Congruences: The linear congruence ax≑b(modn)ax \equiv b \pmod n has solutions if and only if gcd⁑(a,n)∣b\gcd(a,n) | b. If this condition holds, there are exactly d=gcd⁑(a,n)d = \gcd(a,n) distinct solutions modulo nn.

    • Euler's Totient Function and Theorems:

    Ο•(n)\phi(n): Counts the number of positive integers less than or equal to nn that are relatively prime to nn.
    Euler's Theorem: If gcd⁑(a,n)=1\gcd(a,n)=1, then aΟ•(n)≑1(modn)a^{\phi(n)} \equiv 1 \pmod n. This is crucial for simplifying large powers.
    * Fermat's Little Theorem: A special case of Euler's Theorem: If pp is a prime number and p∀ap \nmid a, then apβˆ’1≑1(modp)a^{p-1} \equiv 1 \pmod p.

    ---

    Chapter Review Questions

    :::question type="MCQ" question="What is the smallest positive integer xx such that 32023x≑9(mod11)3^{2023}x \equiv 9 \pmod{11}?" options=["A) 1","B) 2","C) 3","D) 4"] answer="D) 4" hint="First, simplify the power of 3 using Fermat's Little Theorem. Then, find the modular inverse of the simplified coefficient." solution="We need to solve 32023x≑9(mod11)3^{2023}x \equiv 9 \pmod{11}.
    First, simplify 32023(mod11)3^{2023} \pmod{11}. Since 1111 is a prime number and 11∀311 \nmid 3, we can use Fermat's Little Theorem, which states apβˆ’1≑1(modp)a^{p-1} \equiv 1 \pmod p. Here, a=3a=3 and p=11p=11, so 311βˆ’1≑310≑1(mod11)3^{11-1} \equiv 3^{10} \equiv 1 \pmod{11}.

    Now, we simplify the exponent 20232023:

    2023=10Γ—202+32023 = 10 \times 202 + 3

    So,
    32023=310Γ—202+3=(310)202β‹…33(mod11)3^{2023} = 3^{10 \times 202 + 3} = (3^{10})^{202} \cdot 3^3 \pmod{11}

    Using Fermat's Little Theorem:
    (1)202β‹…33≑1β‹…27(mod11)(1)^{202} \cdot 3^3 \equiv 1 \cdot 27 \pmod{11}

    27≑5(mod11)(sinceΒ 27=2Γ—11+5)27 \equiv 5 \pmod{11} \quad (\text{since } 27 = 2 \times 11 + 5)

    The congruence becomes:
    5x≑9(mod11)5x \equiv 9 \pmod{11}

    To find xx, we need to multiply by the modular inverse of 5(mod11)5 \pmod{11}.
    Let 5βˆ’1(mod11)5^{-1} \pmod{11} be yy. We need 5y≑1(mod11)5y \equiv 1 \pmod{11}.
    By inspection, 5Γ—9=45≑1(mod11)5 \times 9 = 45 \equiv 1 \pmod{11}. So 5βˆ’1≑9(mod11)5^{-1} \equiv 9 \pmod{11}.
    Multiply both sides of 5x≑9(mod11)5x \equiv 9 \pmod{11} by 99:
    9β‹…5x≑9β‹…9(mod11)9 \cdot 5x \equiv 9 \cdot 9 \pmod{11}

    45x≑81(mod11)45x \equiv 81 \pmod{11}

    1x≑81(mod11)1x \equiv 81 \pmod{11}

    Since 81=7Γ—11+481 = 7 \times 11 + 4, we have 81≑4(mod11)81 \equiv 4 \pmod{11}.
    Thus,
    x≑4(mod11)x \equiv 4 \pmod{11}

    The smallest positive integer xx is 44.

    Answer: D\boxed{D}
    "
    :::

    :::question type="NAT" question="Find the smallest positive integer xx such that 17x≑1(mod101)17x \equiv 1 \pmod{101}." answer="6" hint="Use the Extended Euclidean Algorithm to find integers aa and bb such that 17a+101b=117a + 101b = 1. The value of aa (modulo 101) will be your answer." solution="We need to find the smallest positive integer xx such that 17x≑1(mod101)17x \equiv 1 \pmod{101}. This is equivalent to finding the modular inverse of 1717 modulo 101101.
    We use the Extended Euclidean Algorithm to find integers aa and bb such that 17a+101b=117a + 101b = 1.

    The steps of the Euclidean Algorithm are:

    101=5Γ—17+16101 = 5 \times 17 + 16

    17=1Γ—16+117 = 1 \times 16 + 1

    16=16Γ—1+016 = 16 \times 1 + 0

    Now, we work backwards from the second equation to express 11 as a linear combination of 1717 and 101101:

    1=17βˆ’1Γ—161=17βˆ’1Γ—(101βˆ’5Γ—17)1=17βˆ’101+5Γ—171=6Γ—17βˆ’1Γ—101\begin{aligned}1 & = 17 - 1 \times 16 \\
    1 & = 17 - 1 \times (101 - 5 \times 17) \\
    1 & = 17 - 101 + 5 \times 17 \\
    1 & = 6 \times 17 - 1 \times 101\end{aligned}

    So, we have 6Γ—17+(βˆ’1)Γ—101=16 \times 17 + (-1) \times 101 = 1.
    Taking this equation modulo 101101:
    6Γ—17+(βˆ’1)Γ—101≑1(mod101)6 \times 17 + (-1) \times 101 \equiv 1 \pmod{101}

    6Γ—17+0≑1(mod101)6 \times 17 + 0 \equiv 1 \pmod{101}

    6Γ—17≑1(mod101)6 \times 17 \equiv 1 \pmod{101}

    Thus, x≑6(mod101)x \equiv 6 \pmod{101}.
    The smallest positive integer xx is 66.

    Answer: 6\boxed{6}
    "
    :::

    :::question type="NAT" question="Find the remainder when 720227^{2022} is divided by 100100." answer="49" hint="Since gcd⁑(7,100)=1\gcd(7,100)=1, use Euler's Totient Theorem. First, calculate Ο•(100)\phi(100). Then simplify the exponent." solution="We need to find 72022(mod100)7^{2022} \pmod{100}.
    Since gcd⁑(7,100)=1\gcd(7,100)=1, we can use Euler's Totient Theorem, which states that aΟ•(n)≑1(modn)a^{\phi(n)} \equiv 1 \pmod n for gcd⁑(a,n)=1\gcd(a,n)=1.
    First, calculate Ο•(100)\phi(100):

    100=22Γ—52100 = 2^2 \times 5^2

    Ο•(100)=100(1βˆ’12)(1βˆ’15)=100(12)(45)=50Γ—45=10Γ—4=40\phi(100) = 100 \left(1 - \frac{1}{2}\right) \left(1 - \frac{1}{5}\right) = 100 \left(\frac{1}{2}\right) \left(\frac{4}{5}\right) = 50 \times \frac{4}{5} = 10 \times 4 = 40

    So, Ο•(100)=40\phi(100) = 40.
    By Euler's Theorem, 740≑1(mod100)7^{40} \equiv 1 \pmod{100}.

    Now, we simplify the exponent 20222022 modulo 4040:

    2022=40Γ—50+222022 = 40 \times 50 + 22

    So,
    72022=740Γ—50+22=(740)50β‹…722(mod100)7^{2022} = 7^{40 \times 50 + 22} = (7^{40})^{50} \cdot 7^{22} \pmod{100}

    Using Euler's Theorem:
    (1)50β‹…722≑722(mod100)(1)^{50} \cdot 7^{22} \equiv 7^{22} \pmod{100}

    Now we need to calculate 722(mod100)7^{22} \pmod{100}:

    71=77^1 = 7

    72=497^2 = 49

    73=49Γ—7=343≑43(mod100)7^3 = 49 \times 7 = 343 \equiv 43 \pmod{100}

    74≑43Γ—7=301≑1(mod100)7^4 \equiv 43 \times 7 = 301 \equiv 1 \pmod{100}

    Since 74≑1(mod100)7^4 \equiv 1 \pmod{100}, we can simplify 7227^{22} further:
    22=4Γ—5+222 = 4 \times 5 + 2

    722=(74)5β‹…72≑(1)5β‹…72≑1β‹…49≑49(mod100)7^{22} = (7^4)^5 \cdot 7^2 \equiv (1)^5 \cdot 7^2 \equiv 1 \cdot 49 \equiv 49 \pmod{100}

    Therefore, the remainder when 720227^{2022} is divided by 100100 is 4949.

    Answer: 49\boxed{49}
    "
    :::

    :::question type="MCQ" question="Consider the congruence 12x≑18(mod42)12x \equiv 18 \pmod{42}. Which of the following statements is true?" options=["A) It has no solutions.","B) It has exactly one solution modulo 42.","C) It has exactly 6 solutions modulo 42.","D) It has exactly 12 solutions modulo 42."] answer="C) It has exactly 6 solutions modulo 42." hint="First, calculate gcd⁑(12,42)\gcd(12, 42). Then check if this gcd⁑\gcd divides 1818. The number of solutions depends on this gcd⁑\gcd." solution="We are given the congruence 12x≑18(mod42)12x \equiv 18 \pmod{42}.

    According to the theory of linear congruences, ax≑b(modn)ax \equiv b \pmod n has solutions if and only if gcd⁑(a,n)\gcd(a,n) divides bb. If solutions exist, there are exactly gcd⁑(a,n)\gcd(a,n) distinct solutions modulo nn.

  • Calculate gcd⁑(12,42)\gcd(12, 42):

  • Using the Euclidean Algorithm:
    42=3Γ—12+642 = 3 \times 12 + 6

    12=2Γ—6+012 = 2 \times 6 + 0

    So, gcd⁑(12,42)=6\gcd(12, 42) = 6.

  • Check if gcd⁑(12,42)\gcd(12, 42) divides 1818:

  • 66 divides 1818 (since 18=3Γ—618 = 3 \times 6).
    Since the condition is met, solutions exist.

  • Determine the number of solutions:

  • The number of distinct solutions modulo 4242 is equal to gcd⁑(12,42)\gcd(12, 42), which is 66.

    Therefore, the congruence 12x≑18(mod42)12x \equiv 18 \pmod{42} has exactly 66 solutions modulo 4242.

    To find these solutions (optional, for verification):
    Divide the entire congruence by gcd⁑(12,42)=6\gcd(12,42)=6:

    126x≑186(mod426)\frac{12}{6}x \equiv \frac{18}{6} \pmod{\frac{42}{6}}

    2x≑3(mod7)2x \equiv 3 \pmod{7}

    Now we need to find the inverse of 2(mod7)2 \pmod{7}.
    2Γ—4=8≑1(mod7)2 \times 4 = 8 \equiv 1 \pmod{7}

    So 2βˆ’1≑4(mod7)2^{-1} \equiv 4 \pmod{7}.
    Multiply both sides by 44:
    4Γ—2x≑4Γ—3(mod7)4 \times 2x \equiv 4 \times 3 \pmod{7}

    8x≑12(mod7)8x \equiv 12 \pmod{7}

    x≑5(mod7)x \equiv 5 \pmod{7}

    This gives us one solution x0=5x_0 = 5. The other solutions are found by adding multiples of n/d=42/6=7n/d = 42/6 = 7 to x0x_0:
    xk=x0+k(nd)forΒ k=0,1,…,dβˆ’1x_k = x_0 + k \left(\frac{n}{d}\right) \quad \text{for } k=0, 1, \dots, d-1

    The solutions modulo 4242 are:
    x0=5x_0 = 5

    x1=5+7=12x_1 = 5 + 7 = 12

    x2=5+2Γ—7=19x_2 = 5 + 2 \times 7 = 19

    x3=5+3Γ—7=26x_3 = 5 + 3 \times 7 = 26

    x4=5+4Γ—7=33x_4 = 5 + 4 \times 7 = 33

    x5=5+5Γ—7=40x_5 = 5 + 5 \times 7 = 40

    There are indeed 6 distinct solutions modulo 42.

    Answer: C\boxed{C}
    "
    :::

    ---

    What's Next?

    πŸ’‘ Continue Your CMI Journey

    You've mastered Modular Arithmetic! This chapter is a cornerstone of Number Theory and its applications in various fields. The principles you've learned here will be indispensable for many advanced topics.

    Key connections:
    Building on Previous Learning: This chapter solidified your understanding of divisibility, prime factorization, greatest common divisors (GCD), and least common multiples (LCM). Modular arithmetic provides a formal framework for analyzing these concepts.
    Foundation for Future Chapters:
    Diophantine Equations: Many integer solutions to linear Diophantine equations are found using modular arithmetic techniques.
    Chinese Remainder Theorem (CRT): This powerful theorem, often covered in the next steps, builds directly on solving systems of linear congruences, which you're now equipped for.
    Quadratic Residues and Reciprocity: These advanced topics in number theory heavily rely on the foundations of modular arithmetic.
    Order of an Element and Primitive Roots: Concepts like the order of an element modulo nn and primitive roots are direct extensions of Euler's and Fermat's theorems.
    * Cryptography: Modern cryptographic systems like RSA are built upon the principles of modular exponentiation, Euler's Totient function, and the difficulty of factoring large numbers.

    Continue practicing these concepts with varied problems. A strong grasp of modular arithmetic will significantly boost your problem-solving capabilities for the CMI entrance exam.

    🎯 Key Points to Remember

    • βœ“ Master the core concepts in Modular Arithmetic before moving to advanced topics
    • βœ“ Practice with previous year questions to understand exam patterns
    • βœ“ Review short notes regularly for quick revision before exams

    Related Topics in Number Theory

    More Resources

    Why Choose MastersUp?

    🎯

    AI-Powered Plans

    Personalized study schedules based on your exam date and learning pace

    πŸ“š

    15,000+ Questions

    Verified questions with detailed solutions from past papers

    πŸ“Š

    Smart Analytics

    Track your progress with subject-wise performance insights

    πŸ”–

    Bookmark & Revise

    Save important questions for quick revision before exams

    Start Your Free Preparation β†’

    No credit card required β€’ Free forever for basic features