introduction to number theory - course websites · why do we care about number theory? backbone of...

66
Introduction to Number Theory Ian Ludden University of Illinois at Urbana-Champaign 14 Sep 2017 Ian Ludden (UIUC) Intro to Number Theory CS173 Fall 2017 1 / 18

Upload: others

Post on 01-Jun-2020

8 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Introduction to Number Theory - Course Websites · Why Do We Care About Number Theory? Backbone of modern cryptography, e.g. RSA Fast, practical algorithms for many problems, e.g

Introduction to Number Theory

Ian Ludden

University of Illinois at Urbana-Champaign

14 Sep 2017

Ian Ludden (UIUC) Intro to Number Theory CS173 Fall 2017 1 / 18

Page 2: Introduction to Number Theory - Course Websites · Why Do We Care About Number Theory? Backbone of modern cryptography, e.g. RSA Fast, practical algorithms for many problems, e.g

Objectives

After today’s lecture, you will be able to:

Define the divides relation and use it in proofs

State the Fundamental Theorem of Arithmetic

Describe the division algorithm

Apply the Euclidean algorithm (and partially explain why it works)

Understand congruence mod k and prove claims involving it

Ian Ludden (UIUC) Intro to Number Theory CS173 Fall 2017 2 / 18

Page 3: Introduction to Number Theory - Course Websites · Why Do We Care About Number Theory? Backbone of modern cryptography, e.g. RSA Fast, practical algorithms for many problems, e.g

Objectives

After today’s lecture, you will be able to:

Define the divides relation and use it in proofs

State the Fundamental Theorem of Arithmetic

Describe the division algorithm

Apply the Euclidean algorithm (and partially explain why it works)

Understand congruence mod k and prove claims involving it

Ian Ludden (UIUC) Intro to Number Theory CS173 Fall 2017 2 / 18

Page 4: Introduction to Number Theory - Course Websites · Why Do We Care About Number Theory? Backbone of modern cryptography, e.g. RSA Fast, practical algorithms for many problems, e.g

Objectives

After today’s lecture, you will be able to:

Define the divides relation and use it in proofs

State the Fundamental Theorem of Arithmetic

Describe the division algorithm

Apply the Euclidean algorithm (and partially explain why it works)

Understand congruence mod k and prove claims involving it

Ian Ludden (UIUC) Intro to Number Theory CS173 Fall 2017 2 / 18

Page 5: Introduction to Number Theory - Course Websites · Why Do We Care About Number Theory? Backbone of modern cryptography, e.g. RSA Fast, practical algorithms for many problems, e.g

Objectives

After today’s lecture, you will be able to:

Define the divides relation and use it in proofs

State the Fundamental Theorem of Arithmetic

Describe the division algorithm

Apply the Euclidean algorithm (and partially explain why it works)

Understand congruence mod k and prove claims involving it

Ian Ludden (UIUC) Intro to Number Theory CS173 Fall 2017 2 / 18

Page 6: Introduction to Number Theory - Course Websites · Why Do We Care About Number Theory? Backbone of modern cryptography, e.g. RSA Fast, practical algorithms for many problems, e.g

Objectives

After today’s lecture, you will be able to:

Define the divides relation and use it in proofs

State the Fundamental Theorem of Arithmetic

Describe the division algorithm

Apply the Euclidean algorithm (and partially explain why it works)

Understand congruence mod k and prove claims involving it

Ian Ludden (UIUC) Intro to Number Theory CS173 Fall 2017 2 / 18

Page 7: Introduction to Number Theory - Course Websites · Why Do We Care About Number Theory? Backbone of modern cryptography, e.g. RSA Fast, practical algorithms for many problems, e.g

Why Do We Care About Number Theory?

Backbone of modern cryptography, e.g. RSA

Fast, practical algorithms for many problems, e.g. modularexponentiation

Pseudo-random algorithms, e.g. for games

Ian Ludden (UIUC) Intro to Number Theory CS173 Fall 2017 3 / 18

Page 8: Introduction to Number Theory - Course Websites · Why Do We Care About Number Theory? Backbone of modern cryptography, e.g. RSA Fast, practical algorithms for many problems, e.g

Why Do We Care About Number Theory?

Backbone of modern cryptography, e.g. RSA

Fast, practical algorithms for many problems, e.g. modularexponentiation

Pseudo-random algorithms, e.g. for games

Ian Ludden (UIUC) Intro to Number Theory CS173 Fall 2017 3 / 18

Page 9: Introduction to Number Theory - Course Websites · Why Do We Care About Number Theory? Backbone of modern cryptography, e.g. RSA Fast, practical algorithms for many problems, e.g

Why Do We Care About Number Theory?

Backbone of modern cryptography, e.g. RSA

Fast, practical algorithms for many problems, e.g. modularexponentiation

Pseudo-random algorithms, e.g. for games

Ian Ludden (UIUC) Intro to Number Theory CS173 Fall 2017 3 / 18

Page 10: Introduction to Number Theory - Course Websites · Why Do We Care About Number Theory? Backbone of modern cryptography, e.g. RSA Fast, practical algorithms for many problems, e.g

The Divides Relation

Definition

Let a and b be integers. Then a divides b (a|b) if and only if b = an forsome integer n. We say b is a multiple of a.

Examples:

5|55, because 55 = 5 · 11

14 6 | 7 (but 7|14, because 14 = 7 · 2)

6|0, because 0 = 6 · 00 6 | n for any non-zero integer n

Ian Ludden (UIUC) Intro to Number Theory CS173 Fall 2017 4 / 18

Page 11: Introduction to Number Theory - Course Websites · Why Do We Care About Number Theory? Backbone of modern cryptography, e.g. RSA Fast, practical algorithms for many problems, e.g

The Divides Relation

Definition

Let a and b be integers. Then a divides b (a|b) if and only if b = an forsome integer n. We say b is a multiple of a.

Examples:

5|55, because 55 = 5 · 11

14 6 | 7 (but 7|14, because 14 = 7 · 2)

6|0, because 0 = 6 · 00 6 | n for any non-zero integer n

Ian Ludden (UIUC) Intro to Number Theory CS173 Fall 2017 4 / 18

Page 12: Introduction to Number Theory - Course Websites · Why Do We Care About Number Theory? Backbone of modern cryptography, e.g. RSA Fast, practical algorithms for many problems, e.g

The Divides Relation

Definition

Let a and b be integers. Then a divides b (a|b) if and only if b = an forsome integer n. We say b is a multiple of a.

Examples:

5|55, because 55 = 5 · 11

14 6 | 7 (but 7|14, because 14 = 7 · 2)

6|0, because 0 = 6 · 00 6 | n for any non-zero integer n

Ian Ludden (UIUC) Intro to Number Theory CS173 Fall 2017 4 / 18

Page 13: Introduction to Number Theory - Course Websites · Why Do We Care About Number Theory? Backbone of modern cryptography, e.g. RSA Fast, practical algorithms for many problems, e.g

The Divides Relation

Definition

Let a and b be integers. Then a divides b (a|b) if and only if b = an forsome integer n. We say b is a multiple of a.

Examples:

5|55, because 55 = 5 · 11

14 6 | 7 (but 7|14, because 14 = 7 · 2)

6|0, because 0 = 6 · 0

0 6 | n for any non-zero integer n

Ian Ludden (UIUC) Intro to Number Theory CS173 Fall 2017 4 / 18

Page 14: Introduction to Number Theory - Course Websites · Why Do We Care About Number Theory? Backbone of modern cryptography, e.g. RSA Fast, practical algorithms for many problems, e.g

The Divides Relation

Definition

Let a and b be integers. Then a divides b (a|b) if and only if b = an forsome integer n. We say b is a multiple of a.

Examples:

5|55, because 55 = 5 · 11

14 6 | 7 (but 7|14, because 14 = 7 · 2)

6|0, because 0 = 6 · 00 6 | n for any non-zero integer n

Ian Ludden (UIUC) Intro to Number Theory CS173 Fall 2017 4 / 18

Page 15: Introduction to Number Theory - Course Websites · Why Do We Care About Number Theory? Backbone of modern cryptography, e.g. RSA Fast, practical algorithms for many problems, e.g

Proof Using Divides

Claim: For any integers p, q and r , where p 6= 0, if p | 3q and 3q | r , thenp | 3q + r .

Proof.

Let p, q, and r be any integers with p 6= 0. Assume p | 3q and 3q | r .That is, for some integers k and m, 3q = pk and r = (3q)m. Consider:

3q + r = pk + (3q)m

= pk + (pk)m

= pk(1 + m)

= p(k(1 + m)).

We have found an integer n = k(1 + m) such that 3q + r = pn, sop | 3q + r .

Ian Ludden (UIUC) Intro to Number Theory CS173 Fall 2017 5 / 18

Page 16: Introduction to Number Theory - Course Websites · Why Do We Care About Number Theory? Backbone of modern cryptography, e.g. RSA Fast, practical algorithms for many problems, e.g

Proof Using Divides

Claim: For any integers p, q and r , where p 6= 0, if p | 3q and 3q | r , thenp | 3q + r .

Proof.

Let p, q, and r be any integers with p 6= 0. Assume p | 3q and 3q | r .

That is, for some integers k and m, 3q = pk and r = (3q)m. Consider:

3q + r = pk + (3q)m

= pk + (pk)m

= pk(1 + m)

= p(k(1 + m)).

We have found an integer n = k(1 + m) such that 3q + r = pn, sop | 3q + r .

Ian Ludden (UIUC) Intro to Number Theory CS173 Fall 2017 5 / 18

Page 17: Introduction to Number Theory - Course Websites · Why Do We Care About Number Theory? Backbone of modern cryptography, e.g. RSA Fast, practical algorithms for many problems, e.g

Proof Using Divides

Claim: For any integers p, q and r , where p 6= 0, if p | 3q and 3q | r , thenp | 3q + r .

Proof.

Let p, q, and r be any integers with p 6= 0. Assume p | 3q and 3q | r .That is, for some integers k and m, 3q = pk and r = (3q)m.

Consider:

3q + r = pk + (3q)m

= pk + (pk)m

= pk(1 + m)

= p(k(1 + m)).

We have found an integer n = k(1 + m) such that 3q + r = pn, sop | 3q + r .

Ian Ludden (UIUC) Intro to Number Theory CS173 Fall 2017 5 / 18

Page 18: Introduction to Number Theory - Course Websites · Why Do We Care About Number Theory? Backbone of modern cryptography, e.g. RSA Fast, practical algorithms for many problems, e.g

Proof Using Divides

Claim: For any integers p, q and r , where p 6= 0, if p | 3q and 3q | r , thenp | 3q + r .

Proof.

Let p, q, and r be any integers with p 6= 0. Assume p | 3q and 3q | r .That is, for some integers k and m, 3q = pk and r = (3q)m. Consider:

3q + r = pk + (3q)m

= pk + (pk)m

= pk(1 + m)

= p(k(1 + m)).

We have found an integer n = k(1 + m) such that 3q + r = pn, sop | 3q + r .

Ian Ludden (UIUC) Intro to Number Theory CS173 Fall 2017 5 / 18

Page 19: Introduction to Number Theory - Course Websites · Why Do We Care About Number Theory? Backbone of modern cryptography, e.g. RSA Fast, practical algorithms for many problems, e.g

Proof Using Divides

Claim: For any integers p, q and r , where p 6= 0, if p | 3q and 3q | r , thenp | 3q + r .

Proof.

Let p, q, and r be any integers with p 6= 0. Assume p | 3q and 3q | r .That is, for some integers k and m, 3q = pk and r = (3q)m. Consider:

3q + r = pk + (3q)m

= pk + (pk)m

= pk(1 + m)

= p(k(1 + m)).

We have found an integer n = k(1 + m) such that 3q + r = pn, sop | 3q + r .

Ian Ludden (UIUC) Intro to Number Theory CS173 Fall 2017 5 / 18

Page 20: Introduction to Number Theory - Course Websites · Why Do We Care About Number Theory? Backbone of modern cryptography, e.g. RSA Fast, practical algorithms for many problems, e.g

Prime Numbers and the FTA

Definition

An integer q ≥ 2 is prime if the only positive factors of q are q and 1. Aninteger q ≥ 2 is composite if it is not prime.

Theorem

Fundamental Theorem of Arithmetic: Every integer q ≥ 2 can bewritten uniquely as the product of one or more prime factors.

Examples:

260 = 2 · 2 · 5 · 13

180 = 2 · 2 · 3 · 3 · 5

Ian Ludden (UIUC) Intro to Number Theory CS173 Fall 2017 6 / 18

Page 21: Introduction to Number Theory - Course Websites · Why Do We Care About Number Theory? Backbone of modern cryptography, e.g. RSA Fast, practical algorithms for many problems, e.g

Prime Numbers and the FTA

Definition

An integer q ≥ 2 is prime if the only positive factors of q are q and 1. Aninteger q ≥ 2 is composite if it is not prime.

Theorem

Fundamental Theorem of Arithmetic: Every integer q ≥ 2 can bewritten uniquely as the product of one or more prime factors.

Examples:

260 = 2 · 2 · 5 · 13

180 = 2 · 2 · 3 · 3 · 5

Ian Ludden (UIUC) Intro to Number Theory CS173 Fall 2017 6 / 18

Page 22: Introduction to Number Theory - Course Websites · Why Do We Care About Number Theory? Backbone of modern cryptography, e.g. RSA Fast, practical algorithms for many problems, e.g

Prime Numbers and the FTA

Definition

An integer q ≥ 2 is prime if the only positive factors of q are q and 1. Aninteger q ≥ 2 is composite if it is not prime.

Theorem

Fundamental Theorem of Arithmetic: Every integer q ≥ 2 can bewritten uniquely as the product of one or more prime factors.

Examples:

260 = 2 · 2 · 5 · 13

180 = 2 · 2 · 3 · 3 · 5

Ian Ludden (UIUC) Intro to Number Theory CS173 Fall 2017 6 / 18

Page 23: Introduction to Number Theory - Course Websites · Why Do We Care About Number Theory? Backbone of modern cryptography, e.g. RSA Fast, practical algorithms for many problems, e.g

Proof of Infinite Primes

Claim: There are infinitely many prime numbers.

Proof.

(By contradiction) Assume there are finitely many primes. Label them p1,p2, ..., pn, where n is the (finite) number of primes.Let p = p1 · p2 · ... · pn + 1.Note that p is greater than every prime, so p is not prime. Therefore, p iscomposite and must be divisible by some prime pi , 1 ≤ i ≤ n.However, if we divide p by pi , we get a remainder of 1, so no pi divides p.Therefore, p is prime, a contradiction. Our assumption that there arefinitely many primes must be false, so there are infinitely many primes.

Ian Ludden (UIUC) Intro to Number Theory CS173 Fall 2017 7 / 18

Page 24: Introduction to Number Theory - Course Websites · Why Do We Care About Number Theory? Backbone of modern cryptography, e.g. RSA Fast, practical algorithms for many problems, e.g

Proof of Infinite Primes

Claim: There are infinitely many prime numbers.

Proof.

(By contradiction) Assume there are finitely many primes. Label them p1,p2, ..., pn, where n is the (finite) number of primes.

Let p = p1 · p2 · ... · pn + 1.Note that p is greater than every prime, so p is not prime. Therefore, p iscomposite and must be divisible by some prime pi , 1 ≤ i ≤ n.However, if we divide p by pi , we get a remainder of 1, so no pi divides p.Therefore, p is prime, a contradiction. Our assumption that there arefinitely many primes must be false, so there are infinitely many primes.

Ian Ludden (UIUC) Intro to Number Theory CS173 Fall 2017 7 / 18

Page 25: Introduction to Number Theory - Course Websites · Why Do We Care About Number Theory? Backbone of modern cryptography, e.g. RSA Fast, practical algorithms for many problems, e.g

Proof of Infinite Primes

Claim: There are infinitely many prime numbers.

Proof.

(By contradiction) Assume there are finitely many primes. Label them p1,p2, ..., pn, where n is the (finite) number of primes.Let p = p1 · p2 · ... · pn + 1.

Note that p is greater than every prime, so p is not prime. Therefore, p iscomposite and must be divisible by some prime pi , 1 ≤ i ≤ n.However, if we divide p by pi , we get a remainder of 1, so no pi divides p.Therefore, p is prime, a contradiction. Our assumption that there arefinitely many primes must be false, so there are infinitely many primes.

Ian Ludden (UIUC) Intro to Number Theory CS173 Fall 2017 7 / 18

Page 26: Introduction to Number Theory - Course Websites · Why Do We Care About Number Theory? Backbone of modern cryptography, e.g. RSA Fast, practical algorithms for many problems, e.g

Proof of Infinite Primes

Claim: There are infinitely many prime numbers.

Proof.

(By contradiction) Assume there are finitely many primes. Label them p1,p2, ..., pn, where n is the (finite) number of primes.Let p = p1 · p2 · ... · pn + 1.Note that p is greater than every prime, so p is not prime. Therefore, p iscomposite and must be divisible by some prime pi , 1 ≤ i ≤ n.

However, if we divide p by pi , we get a remainder of 1, so no pi divides p.Therefore, p is prime, a contradiction. Our assumption that there arefinitely many primes must be false, so there are infinitely many primes.

Ian Ludden (UIUC) Intro to Number Theory CS173 Fall 2017 7 / 18

Page 27: Introduction to Number Theory - Course Websites · Why Do We Care About Number Theory? Backbone of modern cryptography, e.g. RSA Fast, practical algorithms for many problems, e.g

Proof of Infinite Primes

Claim: There are infinitely many prime numbers.

Proof.

(By contradiction) Assume there are finitely many primes. Label them p1,p2, ..., pn, where n is the (finite) number of primes.Let p = p1 · p2 · ... · pn + 1.Note that p is greater than every prime, so p is not prime. Therefore, p iscomposite and must be divisible by some prime pi , 1 ≤ i ≤ n.However, if we divide p by pi , we get a remainder of 1, so no pi divides p.Therefore, p is prime, a contradiction. Our assumption that there arefinitely many primes must be false, so there are infinitely many primes.

Ian Ludden (UIUC) Intro to Number Theory CS173 Fall 2017 7 / 18

Page 28: Introduction to Number Theory - Course Websites · Why Do We Care About Number Theory? Backbone of modern cryptography, e.g. RSA Fast, practical algorithms for many problems, e.g

Caution: Some False Things Seem True

There are some conjectures that seem true because it’s hard to find acounterexample.

Claim: ∀n ∈ Z, n2 + n + 41 is prime.

12 + 1 + 41 = 43 is prime

22 + 2 + 41 = 47 is prime

32 + 3 + 41 = 53 is prime

Looks good so far...

412 + 41 + 41 = 41(41) + 41(1) + 41(1) = 41 · 43 is not prime

Takeaway: Don’t believe a mathematical claim, even though it looks true,until you have a proof.

Ian Ludden (UIUC) Intro to Number Theory CS173 Fall 2017 8 / 18

Page 29: Introduction to Number Theory - Course Websites · Why Do We Care About Number Theory? Backbone of modern cryptography, e.g. RSA Fast, practical algorithms for many problems, e.g

Caution: Some False Things Seem True

There are some conjectures that seem true because it’s hard to find acounterexample.

Claim: ∀n ∈ Z, n2 + n + 41 is prime.

12 + 1 + 41 = 43 is prime

22 + 2 + 41 = 47 is prime

32 + 3 + 41 = 53 is prime

Looks good so far...

412 + 41 + 41 = 41(41) + 41(1) + 41(1) = 41 · 43 is not prime

Takeaway: Don’t believe a mathematical claim, even though it looks true,until you have a proof.

Ian Ludden (UIUC) Intro to Number Theory CS173 Fall 2017 8 / 18

Page 30: Introduction to Number Theory - Course Websites · Why Do We Care About Number Theory? Backbone of modern cryptography, e.g. RSA Fast, practical algorithms for many problems, e.g

Caution: Some False Things Seem True

There are some conjectures that seem true because it’s hard to find acounterexample.

Claim: ∀n ∈ Z, n2 + n + 41 is prime.

12 + 1 + 41 = 43 is prime

22 + 2 + 41 = 47 is prime

32 + 3 + 41 = 53 is prime

Looks good so far...

412 + 41 + 41 = 41(41) + 41(1) + 41(1) = 41 · 43 is not prime

Takeaway: Don’t believe a mathematical claim, even though it looks true,until you have a proof.

Ian Ludden (UIUC) Intro to Number Theory CS173 Fall 2017 8 / 18

Page 31: Introduction to Number Theory - Course Websites · Why Do We Care About Number Theory? Backbone of modern cryptography, e.g. RSA Fast, practical algorithms for many problems, e.g

Caution: Some False Things Seem True

There are some conjectures that seem true because it’s hard to find acounterexample.

Claim: ∀n ∈ Z, n2 + n + 41 is prime.

12 + 1 + 41 = 43 is prime

22 + 2 + 41 = 47 is prime

32 + 3 + 41 = 53 is prime

Looks good so far...

412 + 41 + 41 = 41(41) + 41(1) + 41(1) = 41 · 43 is not prime

Takeaway: Don’t believe a mathematical claim, even though it looks true,until you have a proof.

Ian Ludden (UIUC) Intro to Number Theory CS173 Fall 2017 8 / 18

Page 32: Introduction to Number Theory - Course Websites · Why Do We Care About Number Theory? Backbone of modern cryptography, e.g. RSA Fast, practical algorithms for many problems, e.g

Caution: Some False Things Seem True

There are some conjectures that seem true because it’s hard to find acounterexample.

Claim: ∀n ∈ Z, n2 + n + 41 is prime.

12 + 1 + 41 = 43 is prime

22 + 2 + 41 = 47 is prime

32 + 3 + 41 = 53 is prime

Looks good so far...

412 + 41 + 41 = 41(41) + 41(1) + 41(1) = 41 · 43 is not prime

Takeaway: Don’t believe a mathematical claim, even though it looks true,until you have a proof.

Ian Ludden (UIUC) Intro to Number Theory CS173 Fall 2017 8 / 18

Page 33: Introduction to Number Theory - Course Websites · Why Do We Care About Number Theory? Backbone of modern cryptography, e.g. RSA Fast, practical algorithms for many problems, e.g

Caution: Some False Things Seem True

There are some conjectures that seem true because it’s hard to find acounterexample.

Claim: ∀n ∈ Z, n2 + n + 41 is prime.

12 + 1 + 41 = 43 is prime

22 + 2 + 41 = 47 is prime

32 + 3 + 41 = 53 is prime

Looks good so far...

412 + 41 + 41 = 41(41) + 41(1) + 41(1) = 41 · 43 is not prime

Takeaway: Don’t believe a mathematical claim, even though it looks true,until you have a proof.

Ian Ludden (UIUC) Intro to Number Theory CS173 Fall 2017 8 / 18

Page 34: Introduction to Number Theory - Course Websites · Why Do We Care About Number Theory? Backbone of modern cryptography, e.g. RSA Fast, practical algorithms for many problems, e.g

Caution: Some False Things Seem True

There are some conjectures that seem true because it’s hard to find acounterexample.

Claim: ∀n ∈ Z, n2 + n + 41 is prime.

12 + 1 + 41 = 43 is prime

22 + 2 + 41 = 47 is prime

32 + 3 + 41 = 53 is prime

Looks good so far...

412 + 41 + 41 = 41(41) + 41(1) + 41(1) = 41 · 43 is not prime

Takeaway: Don’t believe a mathematical claim, even though it looks true,until you have a proof.

Ian Ludden (UIUC) Intro to Number Theory CS173 Fall 2017 8 / 18

Page 35: Introduction to Number Theory - Course Websites · Why Do We Care About Number Theory? Backbone of modern cryptography, e.g. RSA Fast, practical algorithms for many problems, e.g

Caution: Some False Things Seem True

There are some conjectures that seem true because it’s hard to find acounterexample.

Claim: ∀n ∈ Z, n2 + n + 41 is prime.

12 + 1 + 41 = 43 is prime

22 + 2 + 41 = 47 is prime

32 + 3 + 41 = 53 is prime

Looks good so far...

412 + 41 + 41 = 41(41) + 41(1) + 41(1) = 41 · 43 is not prime

Takeaway: Don’t believe a mathematical claim, even though it looks true,until you have a proof.

Ian Ludden (UIUC) Intro to Number Theory CS173 Fall 2017 8 / 18

Page 36: Introduction to Number Theory - Course Websites · Why Do We Care About Number Theory? Backbone of modern cryptography, e.g. RSA Fast, practical algorithms for many problems, e.g

GCD and LCM

Definition

if c | a and c | b, then c is a common divisor of a and b. The largestsuch number is the greatest common divisor (GCD) of a and b, writtenas gcd(a, b).

Definition

if a | c and b | c , then c is a common multiple of a and b. The smallestsuch number is the least common multiple (LCM) of a and b, writtenas lcm(a, b).

Fact

lcm(a, b) =ab

gcd(a, b)

Ian Ludden (UIUC) Intro to Number Theory CS173 Fall 2017 9 / 18

Page 37: Introduction to Number Theory - Course Websites · Why Do We Care About Number Theory? Backbone of modern cryptography, e.g. RSA Fast, practical algorithms for many problems, e.g

GCD and LCM

Definition

if c | a and c | b, then c is a common divisor of a and b. The largestsuch number is the greatest common divisor (GCD) of a and b, writtenas gcd(a, b).

Definition

if a | c and b | c , then c is a common multiple of a and b. The smallestsuch number is the least common multiple (LCM) of a and b, writtenas lcm(a, b).

Fact

lcm(a, b) =ab

gcd(a, b)

Ian Ludden (UIUC) Intro to Number Theory CS173 Fall 2017 9 / 18

Page 38: Introduction to Number Theory - Course Websites · Why Do We Care About Number Theory? Backbone of modern cryptography, e.g. RSA Fast, practical algorithms for many problems, e.g

GCD and LCM

Definition

if c | a and c | b, then c is a common divisor of a and b. The largestsuch number is the greatest common divisor (GCD) of a and b, writtenas gcd(a, b).

Definition

if a | c and b | c , then c is a common multiple of a and b. The smallestsuch number is the least common multiple (LCM) of a and b, writtenas lcm(a, b).

Fact

lcm(a, b) =ab

gcd(a, b)

Ian Ludden (UIUC) Intro to Number Theory CS173 Fall 2017 9 / 18

Page 39: Introduction to Number Theory - Course Websites · Why Do We Care About Number Theory? Backbone of modern cryptography, e.g. RSA Fast, practical algorithms for many problems, e.g

The Division Algorithm

Theorem

For any integers a and b, where b > 0, there are unique integers q (thequotient) and r (the remainder) such that a = bq + r and 0 ≤ r < b.

Examples:

Divide 17 by 3: 17 = 5 · 3 + 2

Divide -10 by 7: −10 = 7 · (−2) + 4

Ian Ludden (UIUC) Intro to Number Theory CS173 Fall 2017 10 / 18

Page 40: Introduction to Number Theory - Course Websites · Why Do We Care About Number Theory? Backbone of modern cryptography, e.g. RSA Fast, practical algorithms for many problems, e.g

The Division Algorithm

Theorem

For any integers a and b, where b > 0, there are unique integers q (thequotient) and r (the remainder) such that a = bq + r and 0 ≤ r < b.

Examples:

Divide 17 by 3: 17 = 5 · 3 + 2

Divide -10 by 7: −10 = 7 · (−2) + 4

Ian Ludden (UIUC) Intro to Number Theory CS173 Fall 2017 10 / 18

Page 41: Introduction to Number Theory - Course Websites · Why Do We Care About Number Theory? Backbone of modern cryptography, e.g. RSA Fast, practical algorithms for many problems, e.g

The Division Algorithm

Theorem

For any integers a and b, where b > 0, there are unique integers q (thequotient) and r (the remainder) such that a = bq + r and 0 ≤ r < b.

Examples:

Divide 17 by 3: 17 = 5 · 3 + 2

Divide -10 by 7: −10 = 7 · (−2) + 4

Ian Ludden (UIUC) Intro to Number Theory CS173 Fall 2017 10 / 18

Page 42: Introduction to Number Theory - Course Websites · Why Do We Care About Number Theory? Backbone of modern cryptography, e.g. RSA Fast, practical algorithms for many problems, e.g

The Euclidean Algorithm

A long time ago, Euclid came up with a fast algorithm for computing gcd.Suppose remainder(a, b) returns the remainder when a is divided by b.Then we can compute the gcd as follows:gcd(a,b: positive integers)

x := a

y := b

while (y > 0)

begin

r := remainder(x,y)

x := y

y := r

end

return x

Ian Ludden (UIUC) Intro to Number Theory CS173 Fall 2017 11 / 18

Page 43: Introduction to Number Theory - Course Websites · Why Do We Care About Number Theory? Backbone of modern cryptography, e.g. RSA Fast, practical algorithms for many problems, e.g

The Euclidean Algorithm (cont.)

Example: Compute gcd(255, 483).

x y r Equation

255 483 255 255 = 483 · 0 + 255483 255 228 483 = 255 · 1 + 228255 228 27 255 = 228 · 1 + 27228 27 12 228 = 27 · 8 + 1227 12 15 27 = 12 · 1 + 1512 15 12 12 = 15 · 0 + 1215 12 3 15 = 12 · 1 + 312 3 0 12 = 3 · 4 + 03 0 3 —

Ian Ludden (UIUC) Intro to Number Theory CS173 Fall 2017 12 / 18

Page 44: Introduction to Number Theory - Course Websites · Why Do We Care About Number Theory? Backbone of modern cryptography, e.g. RSA Fast, practical algorithms for many problems, e.g

The Euclidean Algorithm: Why it Works

For the Euclidean algorithm to work, it needs to:

(a) terminate (i.e. y needs to eventually become 0).

(b) not change the output gcd when resetting variables inside the loop.

(c) return a at the end because gcd(a, 0) = a.

Ian Ludden (UIUC) Intro to Number Theory CS173 Fall 2017 13 / 18

Page 45: Introduction to Number Theory - Course Websites · Why Do We Care About Number Theory? Backbone of modern cryptography, e.g. RSA Fast, practical algorithms for many problems, e.g

The Euclidean Algorithm: Sketch of Proof

Claim: gcd(a, b) = gcd(b, remainder(a, b)).

Proof.

Suppose a = bq + r .

Lemma 1: Any k that divides a and b also divides r .

Lemma 2: Any k that divides b and r also divides a.

Therefore, the set of common factors of a and b is the same as theset of common factors of b and r .

We conclude that gcd(a, b) = gcd(b, remainder(a, b)), since identicalsets of common factors will have the same maximum.

Ian Ludden (UIUC) Intro to Number Theory CS173 Fall 2017 14 / 18

Page 46: Introduction to Number Theory - Course Websites · Why Do We Care About Number Theory? Backbone of modern cryptography, e.g. RSA Fast, practical algorithms for many problems, e.g

The Euclidean Algorithm: Sketch of Proof

Claim: gcd(a, b) = gcd(b, remainder(a, b)).

Proof.

Suppose a = bq + r .

Lemma 1: Any k that divides a and b also divides r .

Lemma 2: Any k that divides b and r also divides a.

Therefore, the set of common factors of a and b is the same as theset of common factors of b and r .

We conclude that gcd(a, b) = gcd(b, remainder(a, b)), since identicalsets of common factors will have the same maximum.

Ian Ludden (UIUC) Intro to Number Theory CS173 Fall 2017 14 / 18

Page 47: Introduction to Number Theory - Course Websites · Why Do We Care About Number Theory? Backbone of modern cryptography, e.g. RSA Fast, practical algorithms for many problems, e.g

The Euclidean Algorithm: Sketch of Proof

Claim: gcd(a, b) = gcd(b, remainder(a, b)).

Proof.

Suppose a = bq + r .

Lemma 1: Any k that divides a and b also divides r .

Lemma 2: Any k that divides b and r also divides a.

Therefore, the set of common factors of a and b is the same as theset of common factors of b and r .

We conclude that gcd(a, b) = gcd(b, remainder(a, b)), since identicalsets of common factors will have the same maximum.

Ian Ludden (UIUC) Intro to Number Theory CS173 Fall 2017 14 / 18

Page 48: Introduction to Number Theory - Course Websites · Why Do We Care About Number Theory? Backbone of modern cryptography, e.g. RSA Fast, practical algorithms for many problems, e.g

The Euclidean Algorithm: Sketch of Proof

Claim: gcd(a, b) = gcd(b, remainder(a, b)).

Proof.

Suppose a = bq + r .

Lemma 1: Any k that divides a and b also divides r .

Lemma 2: Any k that divides b and r also divides a.

Therefore, the set of common factors of a and b is the same as theset of common factors of b and r .

We conclude that gcd(a, b) = gcd(b, remainder(a, b)), since identicalsets of common factors will have the same maximum.

Ian Ludden (UIUC) Intro to Number Theory CS173 Fall 2017 14 / 18

Page 49: Introduction to Number Theory - Course Websites · Why Do We Care About Number Theory? Backbone of modern cryptography, e.g. RSA Fast, practical algorithms for many problems, e.g

The Euclidean Algorithm: Sketch of Proof

Claim: gcd(a, b) = gcd(b, remainder(a, b)).

Proof.

Suppose a = bq + r .

Lemma 1: Any k that divides a and b also divides r .

Lemma 2: Any k that divides b and r also divides a.

Therefore, the set of common factors of a and b is the same as theset of common factors of b and r .

We conclude that gcd(a, b) = gcd(b, remainder(a, b)), since identicalsets of common factors will have the same maximum.

Ian Ludden (UIUC) Intro to Number Theory CS173 Fall 2017 14 / 18

Page 50: Introduction to Number Theory - Course Websites · Why Do We Care About Number Theory? Backbone of modern cryptography, e.g. RSA Fast, practical algorithms for many problems, e.g

The Euclidean Algorithm: Sketch of Proof

Claim: gcd(a, b) = gcd(b, remainder(a, b)).

Proof.

Suppose a = bq + r .

Lemma 1: Any k that divides a and b also divides r .

Lemma 2: Any k that divides b and r also divides a.

Therefore, the set of common factors of a and b is the same as theset of common factors of b and r .

We conclude that gcd(a, b) = gcd(b, remainder(a, b)), since identicalsets of common factors will have the same maximum.

Ian Ludden (UIUC) Intro to Number Theory CS173 Fall 2017 14 / 18

Page 51: Introduction to Number Theory - Course Websites · Why Do We Care About Number Theory? Backbone of modern cryptography, e.g. RSA Fast, practical algorithms for many problems, e.g

The Euclidean Algorithm: Sketch of Proof

Lemma 1: Any k that divides a and b also divides r .

Proof.

Let a, b, q, r , and k be integers. Suppose a = bq + r , k | a, and k | b.

Since k | a, a = kn for some integer n. Since k | b, b = km for someinteger m.

Since a = bq + r , r = a− bq.

So r = kn − (km)q = k(n −mq).

We know n −mq is an integer, so k | r .

Ian Ludden (UIUC) Intro to Number Theory CS173 Fall 2017 15 / 18

Page 52: Introduction to Number Theory - Course Websites · Why Do We Care About Number Theory? Backbone of modern cryptography, e.g. RSA Fast, practical algorithms for many problems, e.g

The Euclidean Algorithm: Sketch of Proof

Lemma 1: Any k that divides a and b also divides r .

Proof.

Let a, b, q, r , and k be integers. Suppose a = bq + r , k | a, and k | b.

Since k | a, a = kn for some integer n. Since k | b, b = km for someinteger m.

Since a = bq + r , r = a− bq.

So r = kn − (km)q = k(n −mq).

We know n −mq is an integer, so k | r .

Ian Ludden (UIUC) Intro to Number Theory CS173 Fall 2017 15 / 18

Page 53: Introduction to Number Theory - Course Websites · Why Do We Care About Number Theory? Backbone of modern cryptography, e.g. RSA Fast, practical algorithms for many problems, e.g

The Euclidean Algorithm: Sketch of Proof

Lemma 1: Any k that divides a and b also divides r .

Proof.

Let a, b, q, r , and k be integers. Suppose a = bq + r , k | a, and k | b.

Since k | a, a = kn for some integer n. Since k | b, b = km for someinteger m.

Since a = bq + r , r = a− bq.

So r = kn − (km)q = k(n −mq).

We know n −mq is an integer, so k | r .

Ian Ludden (UIUC) Intro to Number Theory CS173 Fall 2017 15 / 18

Page 54: Introduction to Number Theory - Course Websites · Why Do We Care About Number Theory? Backbone of modern cryptography, e.g. RSA Fast, practical algorithms for many problems, e.g

The Euclidean Algorithm: Sketch of Proof

Lemma 1: Any k that divides a and b also divides r .

Proof.

Let a, b, q, r , and k be integers. Suppose a = bq + r , k | a, and k | b.

Since k | a, a = kn for some integer n. Since k | b, b = km for someinteger m.

Since a = bq + r , r = a− bq.

So r = kn − (km)q = k(n −mq).

We know n −mq is an integer, so k | r .

Ian Ludden (UIUC) Intro to Number Theory CS173 Fall 2017 15 / 18

Page 55: Introduction to Number Theory - Course Websites · Why Do We Care About Number Theory? Backbone of modern cryptography, e.g. RSA Fast, practical algorithms for many problems, e.g

The Euclidean Algorithm: Sketch of Proof

Lemma 1: Any k that divides a and b also divides r .

Proof.

Let a, b, q, r , and k be integers. Suppose a = bq + r , k | a, and k | b.

Since k | a, a = kn for some integer n. Since k | b, b = km for someinteger m.

Since a = bq + r , r = a− bq.

So r = kn − (km)q = k(n −mq).

We know n −mq is an integer, so k | r .

Ian Ludden (UIUC) Intro to Number Theory CS173 Fall 2017 15 / 18

Page 56: Introduction to Number Theory - Course Websites · Why Do We Care About Number Theory? Backbone of modern cryptography, e.g. RSA Fast, practical algorithms for many problems, e.g

Congruence mod k

Definition

If k is any positive integer, two integers a and b are congruent mod k ifk | (a− b).We write this as a ≡ b (mod k).

Examples:

3 ≡ 38 (mod 7)

19 ≡ 7 (mod 12)

−22 ≡ 3 (mod 5)

Ian Ludden (UIUC) Intro to Number Theory CS173 Fall 2017 16 / 18

Page 57: Introduction to Number Theory - Course Websites · Why Do We Care About Number Theory? Backbone of modern cryptography, e.g. RSA Fast, practical algorithms for many problems, e.g

Congruence mod k

Definition

If k is any positive integer, two integers a and b are congruent mod k ifk | (a− b).We write this as a ≡ b (mod k).

Examples:

3 ≡ 38 (mod 7)

19 ≡ 7 (mod 12)

−22 ≡ 3 (mod 5)

Ian Ludden (UIUC) Intro to Number Theory CS173 Fall 2017 16 / 18

Page 58: Introduction to Number Theory - Course Websites · Why Do We Care About Number Theory? Backbone of modern cryptography, e.g. RSA Fast, practical algorithms for many problems, e.g

Congruence mod k

Definition

If k is any positive integer, two integers a and b are congruent mod k ifk | (a− b).We write this as a ≡ b (mod k).

Examples:

3 ≡ 38 (mod 7)

19 ≡ 7 (mod 12)

−22 ≡ 3 (mod 5)

Ian Ludden (UIUC) Intro to Number Theory CS173 Fall 2017 16 / 18

Page 59: Introduction to Number Theory - Course Websites · Why Do We Care About Number Theory? Backbone of modern cryptography, e.g. RSA Fast, practical algorithms for many problems, e.g

Proof with Congruence mod k

Claim: For any integers a, b, c, d , and k , where k > 0, if a ≡ b (mod k)and c ≡ d (mod k), then ac ≡ bd (mod k).

Proof.

Let a, b, c , and d be any integers, and let k be any positive integer.Suppose a ≡ b (mod k) and c ≡ d (mod k).

By definition of congruence mod k, k | (a− b) and k | (c − d). Bydefinition of divides, this means (a− b) = kn and (c − d) = km,where n and m are integers. So a = b + kn and c = d + km.

Multiplying, we have ac = bd + bkm + dkn + k2nm.

So ac = bd + k(bm + dn + knm).

Let q = bm + dn + knm. Since b, d , n,m, and k are integers, q is aninteger. Then, ac = bd + kq, which means (ac − bd) = kq.

So k | (ac − bd). By definition of congruence mod k,ac ≡ bd (mod k).

Ian Ludden (UIUC) Intro to Number Theory CS173 Fall 2017 17 / 18

Page 60: Introduction to Number Theory - Course Websites · Why Do We Care About Number Theory? Backbone of modern cryptography, e.g. RSA Fast, practical algorithms for many problems, e.g

Proof with Congruence mod k

Claim: For any integers a, b, c, d , and k , where k > 0, if a ≡ b (mod k)and c ≡ d (mod k), then ac ≡ bd (mod k).

Proof.

Let a, b, c , and d be any integers, and let k be any positive integer.Suppose a ≡ b (mod k) and c ≡ d (mod k).

By definition of congruence mod k , k | (a− b) and k | (c − d). Bydefinition of divides, this means (a− b) = kn and (c − d) = km,where n and m are integers. So a = b + kn and c = d + km.

Multiplying, we have ac = bd + bkm + dkn + k2nm.

So ac = bd + k(bm + dn + knm).

Let q = bm + dn + knm. Since b, d , n,m, and k are integers, q is aninteger. Then, ac = bd + kq, which means (ac − bd) = kq.

So k | (ac − bd). By definition of congruence mod k ,ac ≡ bd (mod k).

Ian Ludden (UIUC) Intro to Number Theory CS173 Fall 2017 17 / 18

Page 61: Introduction to Number Theory - Course Websites · Why Do We Care About Number Theory? Backbone of modern cryptography, e.g. RSA Fast, practical algorithms for many problems, e.g

Proof with Congruence mod k

Claim: For any integers a, b, c, d , and k , where k > 0, if a ≡ b (mod k)and c ≡ d (mod k), then ac ≡ bd (mod k).

Proof.

Let a, b, c , and d be any integers, and let k be any positive integer.Suppose a ≡ b (mod k) and c ≡ d (mod k).

By definition of congruence mod k , k | (a− b) and k | (c − d). Bydefinition of divides, this means (a− b) = kn and (c − d) = km,where n and m are integers. So a = b + kn and c = d + km.

Multiplying, we have ac = bd + bkm + dkn + k2nm.

So ac = bd + k(bm + dn + knm).

Let q = bm + dn + knm. Since b, d , n,m, and k are integers, q is aninteger. Then, ac = bd + kq, which means (ac − bd) = kq.

So k | (ac − bd). By definition of congruence mod k ,ac ≡ bd (mod k).

Ian Ludden (UIUC) Intro to Number Theory CS173 Fall 2017 17 / 18

Page 62: Introduction to Number Theory - Course Websites · Why Do We Care About Number Theory? Backbone of modern cryptography, e.g. RSA Fast, practical algorithms for many problems, e.g

Proof with Congruence mod k

Claim: For any integers a, b, c, d , and k , where k > 0, if a ≡ b (mod k)and c ≡ d (mod k), then ac ≡ bd (mod k).

Proof.

Let a, b, c , and d be any integers, and let k be any positive integer.Suppose a ≡ b (mod k) and c ≡ d (mod k).

By definition of congruence mod k , k | (a− b) and k | (c − d). Bydefinition of divides, this means (a− b) = kn and (c − d) = km,where n and m are integers. So a = b + kn and c = d + km.

Multiplying, we have ac = bd + bkm + dkn + k2nm.

So ac = bd + k(bm + dn + knm).

Let q = bm + dn + knm. Since b, d , n,m, and k are integers, q is aninteger. Then, ac = bd + kq, which means (ac − bd) = kq.

So k | (ac − bd). By definition of congruence mod k ,ac ≡ bd (mod k).

Ian Ludden (UIUC) Intro to Number Theory CS173 Fall 2017 17 / 18

Page 63: Introduction to Number Theory - Course Websites · Why Do We Care About Number Theory? Backbone of modern cryptography, e.g. RSA Fast, practical algorithms for many problems, e.g

Proof with Congruence mod k

Claim: For any integers a, b, c, d , and k , where k > 0, if a ≡ b (mod k)and c ≡ d (mod k), then ac ≡ bd (mod k).

Proof.

Let a, b, c , and d be any integers, and let k be any positive integer.Suppose a ≡ b (mod k) and c ≡ d (mod k).

By definition of congruence mod k , k | (a− b) and k | (c − d). Bydefinition of divides, this means (a− b) = kn and (c − d) = km,where n and m are integers. So a = b + kn and c = d + km.

Multiplying, we have ac = bd + bkm + dkn + k2nm.

So ac = bd + k(bm + dn + knm).

Let q = bm + dn + knm. Since b, d , n,m, and k are integers, q is aninteger. Then, ac = bd + kq, which means (ac − bd) = kq.

So k | (ac − bd). By definition of congruence mod k ,ac ≡ bd (mod k).

Ian Ludden (UIUC) Intro to Number Theory CS173 Fall 2017 17 / 18

Page 64: Introduction to Number Theory - Course Websites · Why Do We Care About Number Theory? Backbone of modern cryptography, e.g. RSA Fast, practical algorithms for many problems, e.g

Proof with Congruence mod k

Claim: For any integers a, b, c, d , and k , where k > 0, if a ≡ b (mod k)and c ≡ d (mod k), then ac ≡ bd (mod k).

Proof.

Let a, b, c , and d be any integers, and let k be any positive integer.Suppose a ≡ b (mod k) and c ≡ d (mod k).

By definition of congruence mod k , k | (a− b) and k | (c − d). Bydefinition of divides, this means (a− b) = kn and (c − d) = km,where n and m are integers. So a = b + kn and c = d + km.

Multiplying, we have ac = bd + bkm + dkn + k2nm.

So ac = bd + k(bm + dn + knm).

Let q = bm + dn + knm. Since b, d , n,m, and k are integers, q is aninteger. Then, ac = bd + kq, which means (ac − bd) = kq.

So k | (ac − bd). By definition of congruence mod k ,ac ≡ bd (mod k).

Ian Ludden (UIUC) Intro to Number Theory CS173 Fall 2017 17 / 18

Page 65: Introduction to Number Theory - Course Websites · Why Do We Care About Number Theory? Backbone of modern cryptography, e.g. RSA Fast, practical algorithms for many problems, e.g

Proof with Congruence mod k

Claim: For any integers a, b, c, d , and k , where k > 0, if a ≡ b (mod k)and c ≡ d (mod k), then ac ≡ bd (mod k).

Proof.

Let a, b, c , and d be any integers, and let k be any positive integer.Suppose a ≡ b (mod k) and c ≡ d (mod k).

By definition of congruence mod k , k | (a− b) and k | (c − d). Bydefinition of divides, this means (a− b) = kn and (c − d) = km,where n and m are integers. So a = b + kn and c = d + km.

Multiplying, we have ac = bd + bkm + dkn + k2nm.

So ac = bd + k(bm + dn + knm).

Let q = bm + dn + knm. Since b, d , n,m, and k are integers, q is aninteger. Then, ac = bd + kq, which means (ac − bd) = kq.

So k | (ac − bd). By definition of congruence mod k ,ac ≡ bd (mod k).

Ian Ludden (UIUC) Intro to Number Theory CS173 Fall 2017 17 / 18

Page 66: Introduction to Number Theory - Course Websites · Why Do We Care About Number Theory? Backbone of modern cryptography, e.g. RSA Fast, practical algorithms for many problems, e.g

References

Building Blocks for Theoretical Computer Science, Ch. 4 by Margaret M. Fleck

Mathematics for Computer Science, Ch. 4 by Lehman, Leighton, and Meyer

Dr. Madhu Parthasarathy’s old lecture slides

Ian Ludden (UIUC) Intro to Number Theory CS173 Fall 2017 18 / 18