CSC165 Discrete Structure

Discrete StructureUnit 56 min read

Number Theory & Modular Arithmetic: Divisibility, Congruences, Primes & Applications

Unit 5 of Discrete Structure covers fundamental concepts of number theory including divisibility, modular arithmetic, prime numbers, and their applications in computer science, with a focus on theoretical foundations and problem-solving techniques.

Unit 5: Number Theory and Modular Arithmetic

5.1 Divisibility and Divisors

Definitions

  • Divisibility: An integer is divisible by an integer if there exists an integer such that . We write .
  • Divisors: For an integer , the set of all divisors of is denoted by .
  • Greatest Common Divisor (GCD): The largest integer that divides two or more integers. Denoted by .
  • Least Common Multiple (LCM): The smallest positive integer that is divisible by two or more integers. Denoted by .

Properties

  • GCD Properties:
    • (Euclidean algorithm).
    • for any integer .
  • LCM Properties:
    • .

Worked Example

Find and .

Solution: Using the Euclidean algorithm:

  1. Thus, .

Now, .


5.2 Prime Numbers and Factorization

Definitions

  • Prime Number: An integer is prime if its only positive divisors are 1 and .
  • Composite Number: An integer that is not prime (i.e., has divisors other than 1 and itself).
  • Fundamental Theorem of Arithmetic: Every integer can be represented uniquely (up to ordering) as a product of prime numbers.

Prime Testing

  • Trial Division: Check divisibility by all integers up to .
  • Fermat's Little Theorem: If is prime and is not divisible by , then .
    • Example: Test if 561 is prime.
      • (561 is a Carmichael number, not prime).

Applications

  • Cryptography (RSA algorithm relies on primality testing).
  • Hashing and error detection in computer science.

5.3 Modular Arithmetic

Definitions

  • Congruence: Two integers and are congruent modulo if . Written as .
  • Modular Arithmetic: Arithmetic operations performed on integers modulo .

Properties

  • Reflexivity: .
  • Symmetry: If , then .
  • Transitivity: If and , then .
  • Addition/Subtraction: and implies and .
  • Multiplication: and implies .

Worked Example

Solve .

Solution: Find the multiplicative inverse of 3 modulo 5. Since , the inverse of 3 is 2. Multiply both sides by 2: . Thus, for any integer .


5.4 Applications in Computer Science

Hashing

  • Modular arithmetic is used to compute hash values (e.g., ).

Cryptography

  • RSA Encryption: Relies on modular exponentiation and properties of primes.
  • Digital Signatures: Use modular inverses for verification.

Pseudorandom Number Generation

  • Linear congruential generators use modular arithmetic: .

5.5 Comparison Table: Key Concepts

Concept Definition Example
Divisibility if for some integer . because .
GCD Largest integer dividing two numbers. .
LCM Smallest common multiple of two numbers. .
Prime Number Integer >1 with no divisors other than 1 and itself. 7 is prime; 9 is not.
Congruence if . .
Modular Arithmetic Arithmetic operations under modulo . .

5.6 Advantages and Disadvantages

Concept Advantages Disadvantages/Limitations
Divisibility Fundamental for number theory and cryptography. Computationally expensive for large numbers.
Prime Testing Essential for security protocols (e.g., RSA). Some primes (e.g., Carmichael numbers) fail Fermat's test.
Modular Arithmetic Efficient for hashing and cyclic operations. Limited to integers; floating-point operations require scaling.

Exam Tip

  1. Understand Definitions: Memorize definitions of divisibility, GCD, LCM, primes, and congruences. Many questions test these directly.
  2. Practice Euclidean Algorithm: Be able to compute GCD and LCM efficiently.
  3. Modular Arithmetic: Know how to solve linear congruences (e.g., ) using inverses.
  4. Prime Testing: Recognize Fermat's Little Theorem and its limitations (e.g., Carmichael numbers).
  5. Applications: Link concepts to real-world uses like cryptography, hashing, and pseudorandom number generation.
  6. Common Mistakes:
    • Forgetting that .
    • Misapplying modular arithmetic (e.g., in general).
    • Confusing and in problems involving divisibility.

Past Exam Questions Covered:

  • Divisibility and set representation (e.g., multiples of 3).
  • Prime testing and Fermat's Little Theorem.
  • Modular arithmetic in congruences.
  • Applications in cryptography and combinatorics (e.g., counting problems).

Based on the TU BSc CSIT syllabus for Discrete Structure (CSC165), unit 5.

Discussion

Loading…