Tải bản đầy đủ
GCD & Linear combination (contd.)

# GCD & Linear combination (contd.)

Tải bản đầy đủ

GCD & Linear combination
(contd.)

Second part of proof

Any other divisor is smaller than d
Let c | a, c | b, c > 0
a = cm, b = cn
d = ax1 + by1 = c(mx1 + ny1)

⇒ c|d
⇒ d is the gcd
Sriram Srinivasan

15/47

Summary 1

All numbers are expressible as unique
products of prime numbers
GCD calculated using Euclid’s algorithm
gcd(a,b) = 1 ⇒ a & b are mutually prime
gcd(a,b) equals the minimum positive
ax+by linear combination

Sriram Srinivasan

16/47

Modular/Clock Arithmetic

1:00 and 13:00 hours are the same
 1:00 and 25:00 hours are the same
1 ≡ 13 (mod 12)
a ≡ b (mod n)
 n is the modulus
 a is “congruent” to b, modulo n
 a - b is divisible by n

a%n=b%n
Sriram Srinivasan

17/47

Modular Arithmetic

a ≡ b (mod n), c ≡ d (mod n)
a - b = jn
c - d = kn

aa++c c- (b
+ k) nn)
≡ +
b d)
+=
d (j(mod

Multiplication
 ac ≡ bd (mod n)
Sriram Srinivasan

18/47

Modular Arithmetic (contd.)

Power

a ≡ b (mod n) ⇒ ak ≡ bk (mod n)
Using induction,
If ak ≡ bk (mod n),
a . ak ≡ b . bk (mod n), by multiplication rule

∴ ak+1 ≡ bk+1 (mod n)
Going n times around the clock
 a + kn ≡ b (mod n)
Sriram Srinivasan

19/47

Chinese Remainder Theorem

m ≡ a (mod p), m ≡ a (mod q)
⇒ m ≡ a (mod pq) (p,q are primes)
m-a = cp.
Now, m-a is expressible as p1. p2 .p3 . . .
If m - a is divisible by both p and q,
p and q must be one of p1 , p2 , p3
⇒ m - a is divisible by pq
Sriram Srinivasan

20/47

GCD and modulus

If gcd(a,n) = 1, and a = b (mod n),
then gcd(b,n) = 1
a ≡ b (mod n) ⇒ a = b + kn
gcd(a,n) = 1
ax1 + ny1 = 1, for some x1 and y1
(b + kn)x1 + ny1 = 1
bx1 + n(kx1 + y1) = bx1 + ny2 = 1
gcd(b,n) = 1
Sriram Srinivasan

21/47

Multiplicative Inverse

If a, b have no common factors, there
exists ai such that a.ai ≡ 1 (mod b)
 ai is called the “multiplicative inverse”
gcd(a,b) = 1 = ax1+ by1, for some x1 and y1
ax1 = 1 – by1
ax1 = 1 + by2

(making y2 = -y1)

ax1 - 1 = by2
ax1 ≡ 1 (mod b) (x1 is the multiplicative inverse)
Sriram Srinivasan
22/47

Summary 2

Modular arithmetic
Chinese Remainder Theorem
 If m ≡ a (mod p) and m ≡ a (mod q),
then m ≡ a (mod pq)
Relationship between gcd and modular
arithmetic
 gcd(a,b) = 1
⇒ aai ≡ 1 (mod b)
Sriram Srinivasan

23/47

Euler’s Totient function

φ(n) = Totient(n)
= Count of integers ≤ n coprime to n
 φ (10) = 4
(1, 3, 7, 9 are coprime to 10)
 φ (7) = 6 (1, 2, 3, 4, 5, 6 coprime to 10)
φ(p) = p - 1, if p is a prime

Sriram Srinivasan

24/47

Totient lemma #2: product

φ(pq) = (p - 1)(q - 1) = φ(p) . φ(q)
 if p and q are prime
Which numbers ≤ pq share factors with pq?
1.p, 2.p, 3.p, … (q-1)p and
1.q, 2.q, 3.q, … (p-1)q and
pq
The rest are coprime to pq. Count them.
φ(pq) = pq - (p - 1) - (q - 1) - 1 = (p - 1)(q - 1)
Sriram Srinivasan

25/47