Loading lessons...
Number Theory: Divisibility, Primes, GCD & LCM
1. Divisibility
For integers a ≠ 0 and b, a divides b (a ∣ b) if b = ak for some integer k.
Properties. If a ∣ b and a ∣ c then a ∣ (b + c) and a ∣ (mb + nc) for all integers m, n. If a ∣ b and b ∣ c then a ∣ c.
Division algorithm. For any integer a and d > 0 there are unique q, r with
Congruence. a ≡ b (mod m) iff m ∣ (a − b). Congruences can be added and multiplied: if a ≡ b and c ≡ d (mod m) then a + c ≡ b + d and ac ≡ bd (mod m).
2. Primes
A prime is an integer p > 1 whose only positive divisors are 1 and p; other integers > 1 are composite.
Fundamental Theorem of Arithmetic. Every integer n > 1 can be written uniquely (up to order) as a product of primes. Example: 252 = 2²·3²·7.
Test. If n is composite it has a prime factor ≤ √n. To test 101: check 2, 3, 5, 7 (since √101 < 11) - none divides, so 101 is prime.
Sieve of Eratosthenes. List 2..n; repeatedly circle the next uncrossed number and cross out its multiples. The survivors are the primes.
Theorem (Euclid). There are infinitely many primes. Proof (contradiction). Suppose p₁, p₂, …, pₙ are all the primes. Let Q = p₁p₂…pₙ + 1. Some prime p divides Q. But p is one of the pᵢ, and pᵢ divides p₁…pₙ, so p would divide Q − p₁…pₙ = 1-impossible. ∎
3. GCD and LCM
- gcd(a, b): the largest integer dividing both. a, b are relatively prime (coprime) if gcd = 1.
- lcm(a, b): the smallest positive integer divisible by both.
From prime factorisations, take min exponents for gcd and max exponents for lcm: 252 = 2²·3²·7, 198 = 2·3²·11 → gcd = 2·3² = 18, lcm = 2²·3²·7·11 = 2772.
4. Euclidean Algorithm
Based on gcd(a, b) = gcd(b, a mod b) and gcd(a, 0) = a.
Euclidean algorithm trace for gcd(252, 198)
| Step | a | b | a mod b |
|---|---|---|---|
| 1 | 252 | 198 | 54 |
| 2 | 198 | 54 | 36 |
| 3 | 54 | 36 | 18 |
| 4 | 36 | 18 | 0 |
gcd(252, 198) = 18. It takes O(log min(a, b)) steps (Lamé's theorem).
Bézout's identity
There exist integers s, t with gcd(a, b) = sa + tb. Work backwards: 18 = 54 − 36 = 54 − (198 − 3·54) = 4·54 − 198 = 4(252 − 198) − 198 = 4·252 − 5·198 ✓ (1008 − 990 = 18).
Consequences
- If p is prime and p ∣ ab, then p ∣ a or p ∣ b (Euclid's lemma).
- ax ≡ 1 (mod m) has a solution (a modular inverse) iff gcd(a, m) = 1. The inverse of 3 mod 7 is 5 because 3·5 = 15 ≡ 1.
📝 IPU End-Term Exam Corner (5-10 Marks)
- Q1. Find gcd(252, 198) by the Euclidean algorithm and express it as a linear combination of 252 and 198. Hence find the lcm. (5 Marks)
- Q2. Prove that there are infinitely many primes. (5 Marks)
- Q3. State the fundamental theorem of arithmetic and prove gcd(a, b)·lcm(a, b) = ab. (5 Marks)