Download Numbers and Divisors

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts

Wieferich prime wikipedia , lookup

Sieve of Eratosthenes wikipedia , lookup

List of prime numbers wikipedia , lookup

Mersenne prime wikipedia , lookup

Prime number theorem wikipedia , lookup

Transcript
Numbers and Divisors!
CSCI 2824, Fall 2012!
!
!
A Graph Theory Problem
•  Imagine that we have a gathering of six
people, some of whom know each other and
some of whom do not. Show that there must
be a trio of people who are mutual friends
or who are mutually unknown to each other.
Assignments
• To read this week: Sections 2.5-2.7 (Ensley/
Crawley)
• For next week: more number theory (no assigned
reading!)
• Problem Set 1 has been sent out to the class via
email; due back (hard copy please!!!) Thurs.
Sept. 20. !
!
!
!!
Mastermind Problem
due 9/27
Find a fourth guess whose scoring will allow
you to determine the secret code (repetitions
are allowed in the code):
O Y P R
Y B O W
B W Y Y
!
!
!
!xx!
!xo!
!o!
Starting out with numbers: the
basic stuff
Natural numbers (as defined in the book):
0, 1, 2, 3, 4, …
Sometimes you’ll hear these described as “whole
numbers”, and the “natural numbers” start at 1.
Integers: … -3, -2, -1, 0, 1, 2, 3, …
Rational numbers: all numbers expressible as
ratios of integers (without 0 in the
denominator).
More basics
Properties of equality:
a = a
If a = b, b = a
If a = b and b = c, then a = c
More basics
Properties of addition and multiplication:
Commutative:
a + b = b + a a * b = b * a
Associative:
a + (b + c) = (a + b) + c
a * (b * c) = (a * b) * c
Distributive:
a * (b + c) = (a * b) + (a * c)
Division Theorem
For positive integers a and d, there are unique
integers q and r such that a = dq + r
where 0 <= r < d
For q and r, think “quotient” and “remainder”.
Note: the remainder is always strictly less than
the divisor.
A Useful Piece of Notation
When the remainder r is 0, we know that d
“divides” a (or you might say, “d goes into
a”). We write this:
d | a
So, for instance, 3 | 6 2 | -8
NOT( 5 | 7 )
17 | 0 Another Useful Piece of Notation
Suppose that when we divide a by n, we get
a certain remainder; and when we divide b
by n, we get the same remainder. Then we
can say:
a mod n = b mod n
or
a ≡n b Equivalence classes in modular
arithmetic
The numbers n such that n ≡2 1:
… -3, -1, 1, 3, 5, …
This is an “equivalence relation”: it has
reflexivity, symmetry, and transitivity (like
numeric equals).
Reflexivity: a ≡ a
Symmetry: If a ≡ b, then b ≡ a
Transivity: If a ≡ b and b ≡ c, then a ≡ c
Quick Practice with Modular
Arithmetic
7 mod 4 = ?
25 mod 11 = ?
-3 mod 10 = ?
0 mod 5 = ?
Divisors
The set of divisors of a positive integer n are all
those integers d whose absolute value is less than
or equal to n and that have the property: d|n
So, for example, the divisors of 18 are:
+/- 1, +/- 2, +/- 3, +/- 6, +/- 9, +/- 18
The divisors of 42 are:
+/- 1, +/- 2, +/- 3, +/- 6, +/- 7, +/- 14, +/- 21, +/42 Primes and GCDs
A prime number is a positive integer >= 2
whose only divisors are 1 and itself.
For any two numbers m and n, gcd(m, n) is the
greatest common divisor shared by m and n.
gcd(14, 35) = 7
gcd(6, 0) = 6 gcd(8, 9) = 1
gcd(7, 5) = 1
Relatively Prime Numbers
Two numbers are relatively prime if their gcd
is 1:
8 and 9 are relatively prime.
12 and 15 are not relatively prime.
Any two distinct primes (e.g., 5 and 11) are
relatively prime.
1 and any number are relatively prime.
A couple of questions
What numbers can be expressed in the form:
12 x + 27 y
where x and y are integers?
A couple of questions
What numbers can be expressed in the form:
13 x + 27 y
where x and y are integers?
A hypothesis
If two numbers m and n are relatively prime,
then we can find integers x and y such that:
m*x + n*y = 1
This implies in turn that any integer can be
expressed in combinations of m and n.
Bezout’s Theorem
If two numbers m and n are relatively prime, then we
can find integers x and y such that:
m*x + n*y = 1
Proof by contradiction:
• Suppose that d is the smallest positive integer such
that m*x + n*y = d, and suppose that d > 1. We’ll
find a positive integer smaller than d that can be
expressed as a combination of m and n.
Okay, let’s get started…
m * x + n * y = d where d > 1
• Now, d can’t divide both m and n, since then they
wouldn’t be relatively prime.
• So let’s say d does not divide m. Then we can
write:
m = d*q + r where 0 < r < d
• So now we can write:
r
=
m – d*q
=
m – (m*x + n*y)*q
=
m(1 – q*x) - n * (q*y)
Okay, let’s get started…
m * x + n * y = d where d > 1
• So now we can write:
r
=
m – d*q
=
m – (m*x + n*y)*q
=
m(1 – q*x) - n * (q*y)
• But hold it! We just showed that r is a combination
of m and n. And we know that r is less than d! So
our original premise can’t be right.
Bezout’s Theorem, Again
If two numbers m and n are relatively prime,
then we can find x and y such that:
m*x + n*y = 1
Try it for any two relatively prime numbers:
7 and 26
9 and 11
A Corollary to Bezout’s
Theorem
If gcd(m, n) = d where d > 1, then we can find
an integer combination of m and n that sums
to d:
m * x + n * y = d
Why? Note that gcd(m/d, n/d) = 1, and then
we can find a combination such that:
(m/d) * x + (n/d) * y = 1
How to find the gcd? (Euclid again!)
We want to find gcd(a, b) where a >= b.
First, we note that if a = b, the answer is a.
Also, if b = 0, the answer is a.
Otherwise, we can find gcd(a, b) by noting
that the greatest common divisor of a and b
is also the greatest common divisor of b and
the remainder r when a is divided by b. Why does this work?
Suppose d|a and d|b. (In prose, d goes into both a and b.)
And suppose a = b*q + r.
Then d|b and d|(a – b*q).
Two examples:
gcd (99, 18) =
gcd(18, 9) =
gcd(9, 0) = 9
gcd(70, 49) =
gcd(49, 21) =
gcd(21, 7) =
gcd(7, 0) = 7 Scheme version of the algorithm
for finding the GCD
!
(define (gcd a b)!
(if !(= b 0) !
! !
!a!
! !
!(gcd b (remainder a
b))))!
!
Not only is this idea super-fast, but it’s
also useful:
(18, 7) = (7, 4) = (4, 3) = (3, 1) = (1, 0) = 1
18 = (2 * 7) + 4
7 = (1* 4) + 3
4 = (1 * 3) + 1
Now, unwind those statements:
1 = 4 – (1 * 3)
= 4 - (1 * (7 – (1 * 4))) = 4 – (7 – 4) = (2 * 4) - 7
= ((2 * (18 – (2 * 7))) – 7 = (2 * 18) – (5 * 7)
The Structure of Divisors
Let’s try to “break down” a number’s divisors
as far as we can:
84 = 2 * 42
= 2 * 2 * 21
= 2 * 2 * 3 * 7
We can’t go any further than this, since we
have only prime factors.
The Fundamental Theorem of
Arithmetic
Every number n has a unique
factorization into primes.
A Lemma
Suppose d|(ab) and gcd(d,a) = 1
In prose: d goes into the product of a and
b, but d and a are relatively prime.
Then d|b
Let’s prove the lemma.
Since
d|ab
We can write:
ab = dq
And since gcd(d, a) = 1
We can find x and y such that:
dx + ay = 1
So: dbx + aby = b
dbx + dqy = b
d(bx + qy) = b
Lemma 2 (a corollary to Lemma 1)
We now know that if d|(ab) and gcd(d,a) = 1,
then d|b. Suppose d is a prime number (let’s
call it p for prime). Then if p|(ab), we know
that either p|a or p|b.
Proof: Suppose p doesn’t go into a. Then by
the definition of greatest common divisor
(and the definition of a “prime number”),
gcd(p,a) = 1. Which means, from our
previous lemma, that p|b.