BIT152 Discrete Structure

Discrete StructureUnit 39 min read

Number Theory: Divisibility, Primes, Congruences & Applications

Unit 3 of Discrete Structure explores fundamental concepts of number theory—divisibility rules, prime numbers, greatest common divisors (GCD), modular arithmetic, and their applications in cryptography, algorithms, and real-world systems like transaction validation (e.g., eSewa) and scheduling (e.g., NTC bus routes).

TAKEAWAYS:

  • Master divisibility rules (e.g., 3, 9, 11) to simplify proofs and computations.
  • Understand Euclid’s algorithm for GCD and its role in cryptography (e.g., RSA encryption).
  • Apply modular arithmetic to solve problems in scheduling, hashing, and cyclic systems.
  • Prove irrationality and primality using fundamental theorems (e.g., Fermat’s Little Theorem).
  • Recognize real-world uses in error detection (e.g., ISBN checks), encryption (e.g., WhatsApp), and resource allocation (e.g., NEPSE stock trading).


Core Concepts and Definitions

1. Divisibility and Divisors

Definition:

  • An integer is divisible by (written ) if there exists an integer such that .
  • Divisors of are all integers where .

Example:

  • Divisors of 12: .
  • Visualization:
-12-11-10-9-8-7-6-5-4-3-2-10123456789101112-12-6-4-3-2-112
Divisors of 12 on the number line (including negatives)

Note: Divisors come in pairs except for perfect squares (e.g., 36 has ).


2. Prime Numbers and Fundamental Theorem of Arithmetic

Definition:

  • A prime number has exactly two distinct positive divisors: 1 and .
  • Composite numbers have more than two divisors.

Fundamental Theorem of Arithmetic: Every integer can be expressed uniquely (up to ordering) as a product of primes: where are primes and are positive integers.

Example:

  • Prime factorization of 60:
2²3560
Prime factorization tree of 60

Why it matters:

  • Used in cryptography (e.g., RSA relies on prime factorization being hard to reverse).
  • Simplifies divisibility proofs (e.g., proving is irrational).

Key Theorems and Proof Techniques

3. Euclid’s Algorithm for GCD

Definition: The greatest common divisor (GCD) of two integers and is the largest integer that divides both. Algorithm:

  1. Divide by , find remainder .
  2. Replace with and with .
  3. Repeat until . The non-zero remainder is .

Worked Example: Find :

48 = 2 × 18 + 12
18 = 1 × 12 + 6
12 = 2 × 6 + 0

Answer: .

Visualization:

graph LR
  A["48 ÷ 18"] -->|"remainder 12"| B["18 ÷ 12"]
  B -->|"remainder 6"| C["12 ÷ 6"]
  C -->|"remainder 0"| D["GCD = 6"]

Application:

  • Used in simplifying fractions (e.g., ).
  • Real-world: eSewa uses GCD to validate transaction amounts (e.g., ensuring no fractional cents in payments).

4. Least Common Multiple (LCM) and Relationship with GCD

Definition: The smallest positive integer divisible by both and . Formula:

Example: Find :

Table Comparison:

Property GCD LCM
Definition Largest common divisor Smallest common multiple
Formula via Euclid
Use Case Simplifying fractions Scheduling (e.g., NTC buses)

Real-world:

  • NTC Bus Routes: If Bus A comes every 12 minutes and Bus B every 18 minutes, they meet every minutes at a stop.

5. Modular Arithmetic

Definition: Two integers and are congruent modulo if , written .

111111012345
Modular clock arithmetic (mod 6)

Properties:

  1. implies for some integer .
  2. Operations preserve congruence:

Example:

  • because and .

Application in Cryptography:

  • WhatsApp Encryption: Uses modular arithmetic to scramble messages. For example, sending a message encrypted as , where is a large prime.

Proof Techniques

6. Proving Irrationality (Example: )

Theorem: is irrational. Proof by Contradiction:

  1. Assume where are coprime integers.
  2. Then ⇒ .
  3. is even ⇒ is even ⇒ .
  4. Substitute: ⇒ .
  5. is even ⇒ is even ⇒ Contradicts being coprime. Conclusion: is irrational.

Visualization of Contradiction:

flowchart TD
  A["Assume √2 = p/q"] --> B["Square both sides: 2q² = p²"]
  B --> C["p² even ⇒ p even"]
  C --> D["p = 2k ⇒ 2q² = 4k² ⇒ q² even ⇒ q even"]
  D --> E["Contradicts coprimality"]
  E --> F["√2 is irrational"]

7. Fermat’s Little Theorem

Theorem: If is prime and is not divisible by , then:

Example: Verify for , : (since is divisible by 5).

Application:

  • Primality Testing: Quickly check if a number is prime (though not foolproof).
  • Digital Signatures: Used in cryptographic protocols (e.g., ElGamal).

## In the Real World

  1. eSewa and Khalti (Transaction Validation):

    • Divisibility Rule: Both apps use modular arithmetic to check transaction amounts. For example, a payment of Rs. 125.75 is rejected if the decimal part doesn’t satisfy (ensuring no fractional paisa errors).
    • GCD in Fraud Detection: If a user sends Rs. 100 to two different accounts simultaneously, the system checks for overlapping divisors to flag anomalies.
  2. NTC Bus Scheduling:

    • LCM for Timetables: Buses on routes with frequencies 10 and 15 minutes meet every minutes at a terminal. This ensures passengers don’t wait indefinitely.
    • Modular Arithmetic for Seat Allocation: Seats are assigned using modulo operations to cycle through available seats efficiently.
  3. NEPSE Stock Trading:

    • Divisibility in Order Matching: When buying/selling shares, the system checks if the quantity is divisible by the lot size (e.g., 100 shares per lot). For example, an order for 150 shares is split into 1 lot of 100 and 1 of 50 (if allowed).
    • Prime Numbers in Encryption: NEPSE’s secure trading platform uses prime-based encryption (like RSA) to protect transaction data.
  4. Pathao’s Ride Matching:

    • Pigeonhole Principle: If Pathao has 100 drivers and 1000 requests in a city, the pigeonhole principle guarantees at least 10 drivers will receive 10 requests each (used for load balancing).

## Exam Tip

  1. Proofs:

    • For irrationality proofs (e.g., ), always use contradiction and assume the opposite.
    • For divisibility proofs, use direct proof or modular arithmetic.
  2. Algorithms:

    • Memorize Euclid’s algorithm steps and practice on numbers like .
    • Know the relationship between GCD and LCM: .
  3. Applications:

    • Link theorems to real-world examples (e.g., "This is how eSewa checks for valid payments").
    • For modular arithmetic, always verify with small numbers (e.g., ).
  4. Common Pitfalls:

    • Off-by-one errors: In divisibility, is always true (since ).
    • Prime checks: 1 is not a prime number. Always verify divisibility up to .
  5. Past Exam Patterns:

    • Direct Proof: "Show that the sum of two odd numbers is even." Solution: Let , . Then , which is even.
    • Pigeonhole Principle: For 24 students and 10 grades, the maximum number of unique grades to ensure a duplicate is (since students would force a repeat by the pigeonhole principle).

Final Note: Number theory is the backbone of secure systems. Master these concepts, and you’ll ace both the exam and real-world problem-solving!

Based on the TU BIT syllabus for Discrete Structure (BIT152), unit 3.

Discussion

Loading…