ScholarQuill logoScholarQuillUniversity Notes
My Semester
Explore Notes
Past Papers12 New
Video CoursesNew
Search
Settings
Study Tools
GPA/CGPA Calculator
Schedule & To-Do
Student Portal
Contact
Contact
ScholarQuill logo
My Semester
Explore Notes
Past Papers12 New
Video CoursesNew
Search
Settings
GPA/CGPA Calculator
Schedule & To-Do
Student Portal
Contact
ScholarQuill logoScholarQuillUniversity Notes
Study PortalGE-167Modular Arithmetic
Ctrl + K
Login
Explore
Search
Semester
Papers
CGPA
    GE-167

    Discrete Structures

    Progress0 / 67 done
    Topics67
    1Propositional and Predicate Logic
    2Logical Operators3Translations Between Symbolic Expressions and Formal English Expression4Logical Equivalences
    5Quantifiers6Nested Quantification7Equivalences in Predicate Logic8Translations Between Symbolic Forms and Formal English
    9Proof Methods and Strategies10Direct Proof11Proof by Contraposition12Proof by Induction13Proof by Implication14Existence Proof15Uniqueness Proofs16Trivial Proofs17Vacuous Proofs
    18Notations and Set Operations19Venn Diagrams20Countable and Uncountable Sets
    21Equivalence Relations and Partitions22Partial Orderings23Recurrence Relations51Reflexive, Symmetric, Transitive, and Antisymmetric52Equivalence Relations and Equivalence Classes53Partial Orders
    24Injective, Surjective, Bijective25Special Types of Functions26Function Composition27Inverse Functions28Recursive Functions29Compositions
    30Sequences and Series
    31Inclusion and Exclusion Principle32Pigeonhole Principle33Permutations and Combinations46Product Rule and Sum Rule47Principle of Inclusion-Exclusion48Binomial Coefficients49Pascal's Identity and Pascal’s Triangle50Binomial Theorem
    34Division Theorem35Modular Arithmetic36LCM and GCD37Euclidean and Extended Euclidean Method38Finding Solutions to Congruence
    39Fundamental Theorem of Arithmetic40Characterizations of Primes41Mersenne Primes
    42Weak Induction43Strong Induction
    44Formulation of Recurrences45Closed Formulas
    54Terminologies55Elements of Graph Theory56Planar Graphs57Graph Coloring58Euler Graph59Hamiltonian Path60Rooted Trees61Graph Traversals62Handshaking Lemma and Corollary63Special Families of Graphs64Graph Isomorphism65Planarity in Graphs66Eulerian and Hamiltonian Graphs67Trees in Graph Theory
    11 min read
    Topic 35 of 67
    Topic Study Note Illustration
    35

    Modular Arithmetic

    Modular arithmetic is a system of arithmetic for integers, where numbers "wrap around" upon reaching a certain value, known as the modulus . It is often described...

    Modular Arithmetic

    Modular arithmetic is a system of arithmetic for integers, where numbers "wrap around" upon reaching a certain value, known as the modulus. It is often described as clock arithmetic because it behaves similarly to how a clock resets after reaching 12 hours. Modular arithmetic is essential in many areas of mathematics, computer science, cryptography, and number theory.

    1. The Basics of Modular Arithmetic

    In modular arithmetic, we are primarily concerned with remainders when dividing numbers by a fixed modulus. The notation used is:

    a≡b(modm)a \equiv b \pmod{m}a≡b(modm)

    This means that when aaa is divided by mmm, the remainder is the same as when bbb is divided by mmm. In other words, aaa and bbb are congruent modulo mmm.

    Explanation:

    • a≡b(modm)a \equiv b \pmod{m}a≡b(modm) if and only if mmm divides a−ba - ba−b, or equivalently, aaa and bbb leave the same remainder when divided by mmm.

    Mathematically, this means:

    a−b=kmfor some integer ka - b = km \quad \text{for some integer } ka−b=kmfor some integer k

    Where kkk is any integer. This implies aaa and bbb are congruent modulo mmm.

    2. Examples of Modular Arithmetic

    Example 1:

    Let's compute 17mod  517 \mod 517mod5:

    • Divide 17 by 5: 17÷5=317 \div 5 = 317÷5=3 with a remainder of 2.
    • So, 17≡2(mod5)17 \equiv 2 \pmod{5}17≡2(mod5).

    This means that 17 and 2 are congruent modulo 5 because both give the same remainder (2) when divided by 5.

    Example 2:

    Compute 29mod  629 \mod 629mod6:

    • Divide 29 by 6: 29÷6=429 \div 6 = 429÷6=4 with a remainder of 5.
    • So, 29≡5(mod6)29 \equiv 5 \pmod{6}29≡5(mod6).

    This means 29 and 5 are congruent modulo 6 because both have the same remainder (5) when divided by 6.

    3. Modular Arithmetic with Negative Numbers

    Modular arithmetic can also be used with negative numbers. The goal is to ensure the remainder is always non-negative and less than the modulus.

    Example 3:

    Compute −17mod  5-17 \mod 5−17mod5:

    • Divide -17 by 5: −17÷5=−4-17 \div 5 = -4−17÷5=−4 (rounding toward negative infinity) with a remainder of 3.
    • So, −17≡3(mod5)-17 \equiv 3 \pmod{5}−17≡3(mod5).

    Here, instead of obtaining a negative remainder, we "adjust" the remainder to be positive by adding the modulus. The remainder is 3 because −17+5×4=3-17 + 5 \times 4 = 3−17+5×4=3.

    General Rule for Negative Numbers:

    When dividing a negative number aaa by mmm, we calculate the remainder as follows:

    • If the remainder rrr is negative, add mmm to rrr until the remainder is positive and less than mmm.

    4. Properties of Modular Arithmetic

    Modular arithmetic follows a set of rules that make calculations easier and more efficient, especially when dealing with large numbers.

    Addition:

    a≡b(modm)andc≡d(modm)⇒a+c≡b+d(modm)a \equiv b \pmod{m} \quad \text{and} \quad c \equiv d \pmod{m} \quad \Rightarrow \quad a + c \equiv b + d \pmod{m}a≡b(modm)andc≡d(modm)⇒a+c≡b+d(modm)

    For example:

    • 7≡2(mod5)7 \equiv 2 \pmod{5}7≡2(mod5) and 9≡4(mod5)9 \equiv 4 \pmod{5}9≡4(mod5), so: 7+9≡2+4(mod5)⇒16≡6(mod5)⇒16≡1(mod5)7 + 9 \equiv 2 + 4 \pmod{5} \quad \Rightarrow \quad 16 \equiv 6 \pmod{5} \quad \Rightarrow \quad 16 \equiv 1 \pmod{5}7+9≡2+4(mod5)⇒16≡6(mod5)⇒16≡1(mod5)

    Multiplication:

    a≡b(modm)andc≡d(modm)⇒a×c≡b×d(modm)a \equiv b \pmod{m} \quad \text{and} \quad c \equiv d \pmod{m} \quad \Rightarrow \quad a \times c \equiv b \times d \pmod{m}a≡b(modm)andc≡d(modm)⇒a×c≡b×d(modm)

    For example:

    • 7≡2(mod5)7 \equiv 2 \pmod{5}7≡2(mod5) and 9≡4(mod5)9 \equiv 4 \pmod{5}9≡4(mod5), so: 7×9≡2×4(mod5)⇒63≡8(mod5)⇒63≡3(mod5)7 \times 9 \equiv 2 \times 4 \pmod{5} \quad \Rightarrow \quad 63 \equiv 8 \pmod{5} \quad \Rightarrow \quad 63 \equiv 3 \pmod{5}7×9≡2×4(mod5)⇒63≡8(mod5)⇒63≡3(mod5)

    Subtraction:

    a≡b(modm)andc≡d(modm)⇒a−c≡b−d(modm)a \equiv b \pmod{m} \quad \text{and} \quad c \equiv d \pmod{m} \quad \Rightarrow \quad a - c \equiv b - d \pmod{m}a≡b(modm)andc≡d(modm)⇒a−c≡b−d(modm)

    Exponentiation:

    ak≡bk(modm)a^k \equiv b^k \pmod{m}ak≡bk(modm)

    Exponentiation in modular arithmetic allows us to compute large powers efficiently using modular exponentiation algorithms (e.g., exponentiation by squaring).

    Example:

    Compute 34mod  53^4 \mod 534mod5:

    • First calculate 34=813^4 = 8134=81.
    • Then calculate 81mod  581 \mod 581mod5: 81÷5=16 (quotient)with remainder81−5×16=81−80=181 \div 5 = 16 \text{ (quotient)} \quad \text{with remainder} \quad 81 - 5 \times 16 = 81 - 80 = 181÷5=16 (quotient)with remainder81−5×16=81−80=1
    • So, 34≡1(mod5)3^4 \equiv 1 \pmod{5}34≡1(mod5).

    5. Modular Inverses

    In modular arithmetic, we often want to "reverse" operations, especially multiplication. For example, we might want to find the modular inverse of a number aaa modulo mmm, which is a number xxx such that:

    a×x≡1(modm)a \times x \equiv 1 \pmod{m}a×x≡1(modm)

    The modular inverse exists only if aaa and mmm are coprime, meaning their greatest common divisor (gcd) is 1, i.e., gcd⁡(a,m)=1\gcd(a, m) = 1gcd(a,m)=1.

    Example:

    Find the modular inverse of 3 modulo 7:

    • We need to find xxx such that 3×x≡1(mod7)3 \times x \equiv 1 \pmod{7}3×x≡1(mod7).
    • Check different values for xxx:
      • 3×1=33 \times 1 = 33×1=3
      • 3×2=63 \times 2 = 63×2=6
      • 3×3=9≡2(mod7)3 \times 3 = 9 \equiv 2 \pmod{7}3×3=9≡2(mod7)
      • 3×4=12≡5(mod7)3 \times 4 = 12 \equiv 5 \pmod{7}3×4=12≡5(mod7)
      • 3×5=15≡1(mod7)3 \times 5 = 15 \equiv 1 \pmod{7}3×5=15≡1(mod7)

    So, the modular inverse of 3 modulo 7 is 5, because 3×5≡1(mod7)3 \times 5 \equiv 1 \pmod{7}3×5≡1(mod7).

    6. Applications of Modular Arithmetic

    1. Cryptography: Modular arithmetic is crucial in modern cryptography, particularly in algorithms like RSA, which rely on modular exponentiation and modular inverses for secure encryption and decryption.

    2. Computer Science: In computer science, modular arithmetic is often used in hashing algorithms, random number generation, and in the design of error-detection and error-correction codes.

    3. Clock Arithmetic: Modular arithmetic is used to model time in a 24-hour or 12-hour clock system, where the hours "wrap around" after reaching a certain value.

    4. Solving Diophantine Equations: Modular arithmetic is used in number theory to solve equations that involve integers and divisibility, such as linear congruences and systems of congruences.

    5. Pseudo-random Number Generation: Modular arithmetic is used in algorithms that generate random numbers, ensuring that the results cycle through a fixed range.

    6. Computer Graphics: In computer graphics, modular arithmetic helps in operations like color manipulation and tiling, where pixel values may "wrap around" within certain bounds.


    7. Conclusion

    Modular arithmetic is a powerful and essential tool in many areas of mathematics, cryptography, and computer science. It allows for efficient computations by focusing on remainders, reducing the size of numbers involved in operations. By understanding modular addition, subtraction, multiplication, exponentiation, and inverses, you can solve a variety of problems that involve large numbers and periodic structures, including encryption, hashing, and number-theoretic applications.

    ← Previous topic 34
    Integers and Divisibility: Division Theorem
    Next topic 36 →
    LCM and GCD

    Past Papers

    Open this section to view and download past papers

    Click on Show Past Papers to load available exam papers.

    Reading Progress
    0%
    11mremaining
    1.9kwords
    Intermediatelevel
    On This Page

    No headings found

    Study Toolkit

    Subject Portal

    Discrete Structures