Discrete StructureUnit 98 min read
Number Theory: Divisibility, Primes, GCD, LCM & Cryptography
Unit 9 of Discrete Structure covers divisibility rules, prime numbers, greatest common divisors (GCD), least common multiples (LCM), modular arithmetic, and their applications in cryptography and real-world systems like eSewa and Ncell.
TAKEAWAYS:
- Divisibility rules simplify checking if one number divides another (e.g., 3 divides a number if the sum of its digits is divisible by 3).
- GCD and LCM are found using the Euclidean algorithm and prime factorization, respectively.
- Modular arithmetic is the foundation of cryptographic systems like RSA and hashing.
- Number theory solves real problems: from eSewa transaction IDs to Ncell’s network routing.
- Prime numbers are the "building blocks" of all integers and are critical in encryption.
- The Euclidean algorithm efficiently computes GCD, even for large numbers.
1. Divisibility and Divisibility Rules
Divisibility means that when integer divides integer (written ), there exists an integer such that . For example, because .
Divisibility Rules (Quick Checks)
| Divisor | Rule |
|---|---|
| 2 | Last digit is even (0, 2, 4, 6, 8). |
| 3 | Sum of digits is divisible by 3. |
| 5 | Last digit is 0 or 5. |
| 9 | Sum of digits is divisible by 9. |
| 11 | Alternating sum of digits is divisible by 11. |
Example: Check if 12345 is divisible by 3.
- Sum of digits: .
- is divisible by 3, so .
Real-World Use:
- eSewa uses divisibility checks to validate transaction IDs (e.g., ensuring a 12-digit ID is divisible by 7 for error detection).
- Ncell’s billing system applies divisibility rules to verify phone numbers and invoice totals.
2. Prime Numbers and Factorization
A prime number is a natural number greater than 1 with no positive divisors other than 1 and itself. The first few primes are 2, 3, 5, 7, 11, etc.
Prime Factorization
Every integer can be expressed as a product of primes: Example: Factorize 60.
Real-World Use:
- RSA Encryption (used by banks and eSewa) relies on the difficulty of factoring large primes.
- NEPSE stock market uses prime-based hashing to secure transaction logs.
3. Greatest Common Divisor (GCD) and Least Common Multiple (LCM)
GCD (Greatest Common Divisor)
The largest number that divides two or more integers without leaving a remainder. Methods to find GCD:
Prime Factorization: For and ,
Euclidean Algorithm (Efficient for large numbers): Example: Compute .
LCM (Least Common Multiple)
The smallest positive integer divisible by both numbers. Relationship between GCD and LCM: Example: Find .
Real-World Use:
- NTC’s network scheduling uses LCM to synchronize signals across towers.
- Khalti’s payment cycles rely on GCD to avoid overlapping transaction deadlines.
4. Modular Arithmetic
Modular arithmetic deals with remainders. For integers (where ): means .
Example: Compute .
Applications:
- Cryptography (RSA): Encryption uses modular exponentiation.
- Hashing (used in databases): Converts large numbers into smaller indices.
Real-World Use:
- Pathao’s ride-matching system uses modular arithmetic to assign drivers to nearby passengers efficiently.
- Ncell’s SIM card PINs are generated using modular operations for security.
5. Cryptography and Number Theory
Cryptography uses number theory to secure data:
Public-Key Cryptography (RSA):
- Relies on the difficulty of factoring large primes.
- Example: If (where are primes), breaking RSA requires finding and .
Hash Functions:
- Use modular arithmetic to produce fixed-length outputs (e.g., SHA-256).
Real-World Example:
- eSewa’s transaction security uses RSA to encrypt payment details.
- NEPSE’s blockchain employs hashing to verify trades.
6. Divisibility Proofs
Theorem: If and , then . Proof: Since , for some integer . Since , for some integer . Thus, . Therefore, .
Real-World Tie-In:
- Bank loan calculations: If a bank charges interest on two loans and , the total repayment must also be divisible by for equal installments.
In the Real World
eSewa’s Transaction IDs:
- Uses divisibility by 7 to validate 12-digit IDs (e.g.,
123456789012must satisfy ). - Why? Ensures no typos slip through before processing.
- Uses divisibility by 7 to validate 12-digit IDs (e.g.,
Ncell’s Network Routing:
- Applies LCM to synchronize signal transmissions across cell towers.
- Example: If Tower A broadcasts every 6 seconds and Tower B every 9 seconds, the LCM (18 seconds) ensures they align.
Khalti’s Payment Deadlines:
- Uses GCD to avoid overlapping transaction deadlines.
- Example: If User A has a 12-hour window and User B has an 18-hour window, the GCD (6 hours) sets the minimum sync period.
NEPSE’s Stock Trading:
- Employs prime-based hashing to secure trade logs.
- Example: A trade ID like
PRIME_7919(where 7919 is a large prime) ensures uniqueness and tamper-proofing.
Pathao’s Driver-Passenger Matching:
- Uses modular arithmetic to assign the nearest available driver.
- Example: If a passenger requests a ride at location , the system computes to find the closest driver zone.
Exam Tip
- Memorize divisibility rules—they appear in short-answer questions.
- Practice the Euclidean algorithm for GCD; it’s often tested in proofs.
- Relate LCM/GCD to real systems (e.g., NTC scheduling, Khalti payments).
- For proofs, always start with definitions (e.g., "Since , ").
- Cryptography questions usually ask about RSA or hashing—link to eSewa/Ncell.
- Watch for traps: In GCD/LCM problems, ensure numbers are co-prime before applying .
Visuals:
graph TD
A["Divisibility Rules"] --> B["2: Even last digit"]
A --> C["3: Sum of digits divisible by 3"]
A --> D["5: Ends with 0 or 5"]
A --> E["11: Alternating sum divisible by 11"]graph LR
A["Prime Factorization"] --> B["48 = 2^4 × 3"]
A --> C["18 = 2 × 3^2"]
B & C --> D["GCD(48,18) = 2 × 3 = 6"]
B & C --> E["LCM(48,18) = 2^4 × 3^2 = 144"]stateDiagram-v2
[*] --> IsPrime: Check if n > 1
IsPrime --> Yes: If yes, check divisibility by primes ≤√n
Yes --> NoDivisors: If no divisors, prime
Yes --> HasDivisors: If divisors exist
HasDivisors --> [*]: Not prime
NoDivisors --> [*]: Primeflowchart TD
A["Euclidean Algorithm"] --> B["Compute 98 ÷ 56 = 1 R42"]
B --> C["Now GCD(56, 42)"]
C --> D["56 ÷ 42 = 1 R14"]
D --> E["Now GCD(42, 14)"]
E --> F["42 ÷ 14 = 3 R0"]
F --> G["GCD = 14"]pie
title Modular Arithmetic in Cryptography
"RSA Encryption" : 45
"Hashing" : 35
"Error Detection" : 20Based on the TU BITM syllabus for Discrete Structure (IT235), unit 9.
Discussion
Loading…