Number Theory

572 words
3 min read
Python Week 1: the first filter for runtime behavior
Visual companion
Python
Type and operator map

Python Week 1: the first filter for runtime behavior

View
Revision summary

What this note is really saying

Short form

# Number Theory ## 🎯 Learning Objectives - Apply divisibility rules and the division algorithm - Use the **Euclidean algorithm** to find GCD - Compute with **modular arithmetic** - Prove properties of primes - Understand the **Fundamental Theorem of Arithmetic** * * * ## 7.1 Divisibility $a \mid b$ means $b = a \cd...

Number Theory

🎯 Learning Objectives

  • Apply divisibility rules and the division algorithm
  • Use the Euclidean algorithm to find GCD
  • Compute with modular arithmetic
  • Prove properties of primes
  • Understand the Fundamental Theorem of Arithmetic

7.1 Divisibility

a∣ba \mid b means b=a⋅kb = a \cdot k for some integer kk. Properties:
  • If a∣ba \mid b and b∣cb \mid c, then a∣ca \mid c (transitive)
  • If a∣ba \mid b and a∣ca \mid c, then a∣(b+c)a \mid (b + c) and a∣(b−c)a \mid (b - c)
  • If a∣ba \mid b, then a∣bca \mid bc for any integer cc

Division Algorithm

For any integers a>0a > 0 and bb, there exist unique integers qq (quotient) and rr (remainder) with 0≤r<a0 \leq r < a such that b=qa+rb = qa + r.

7.2 GCD and Euclidean Algorithm

gcd⁡(a,b)\gcd(a,b) is the largest integer dividing both aa and bb. Euclidean Algorithm:
  1. a=q1b+r1a = q_1 b + r_1 (0≤r1<b0 \leq r_1 < b)
  2. b=q2r1+r2b = q_2 r_1 + r_2 (0≤r2<r10 \leq r_2 < r_1)
  3. r1=q3r2+r3r_1 = q_3 r_2 + r_3
  4. Continue until remainder = 0. The last non-zero remainder is gcd⁡(a,b)\gcd(a,b).

Example: gcd⁡(1071,462)\gcd(1071, 462)

  • 1071=2×462+1471071 = 2 \times 462 + 147
  • 462=3×147+21462 = 3 \times 147 + 21
  • 147=7×21+0147 = 7 \times 21 + 0
  • gcd⁡(1071,462)=21\gcd(1071, 462) = 21

7.3 Modular Arithmetic

a≡b(modn)a \equiv b \pmod{n} means n∣(a−b)n \mid (a - b). Properties:
  • If a≡b(modn)a \equiv b \pmod{n} and c≡d(modn)c \equiv d \pmod{n}, then a+c≡b+d(modn)a + c \equiv b + d \pmod{n} and ac≡bd(modn)ac \equiv bd \pmod{n}
  • a≡b(modn)  ⟹  ak≡bk(modn)a \equiv b \pmod{n} \implies a^k \equiv b^k \pmod{n}

Application: Divisibility Tests

A number is divisible by 9 iff the sum of its digits is divisible by 9 — because 10≡1(mod9)10 \equiv 1 \pmod{9}.

7.4 Prime Numbers

A prime pp is an integer >1>1 with no positive divisors other than 1 and pp.

Fundamental Theorem of Arithmetic

Every integer n≥2n \geq 2 can be written uniquely as a product of primes (up to order).

Infinitely Many Primes (Euclid's Proof)

Assume finite list p1,…,pkp_1, \dots, p_k. N=p1p2⋯pk+1N = p_1p_2\cdots p_k + 1 is either prime (contradiction) or has a prime factor not in the list. Contradiction.

✅ Practice Questions

Q1: Find gcd⁡(123,45)\gcd(123, 45) using Euclidean algorithm.
Solution
123=2×45+33123 = 2 \times 45 + 33 45=1×33+1245 = 1 \times 33 + 12 33=2×12+933 = 2 \times 12 + 9 12=1×9+312 = 1 \times 9 + 3 9=3×3+09 = 3 \times 3 + 0 gcd⁡(123,45)=3\gcd(123, 45) = 3 Q2: Compute 7100(mod5)7^{100} \pmod{5}. Solution
7≡2(mod5)7 \equiv 2 \pmod{5}, so 7100≡2100(mod5)7^{100} \equiv 2^{100} \pmod{5}. 24=16≡1(mod5)2^4 = 16 \equiv 1 \pmod{5}. 2100=(24)25≡125=1(mod5)2^{100} = (2^4)^{25} \equiv 1^{25} = 1 \pmod{5}. So 7100≡1(mod5)7^{100} \equiv 1 \pmod{5}. Q3: Prove that if pp is prime and p∣abp \mid ab, then p∣ap \mid a or p∣bp \mid b (Euclid's lemma). Solution
Assume pp prime, p∣abp \mid ab, and p∤ap \nmid a. Then gcd⁡(a,p)=1\gcd(a,p) = 1 (since pp is prime, its only divisors are 1 and pp). By Bézout's identity, there exist integers x,yx,y such that ax+py=1ax + py = 1. Multiply by bb: abx+pby=babx + pby = b. Since p∣abp \mid ab, p∣abxp \mid abx, and p∣pbyp \mid pby, so p∣bp \mid b. Join Discord PreviousRelations and FunctionsNextModular Arithmetic Deep
Document outline

Keep your place and jump directly to a heading.

Table of contents

No note selected

Open a chapter to see its outline, backlinks, and sources here.