Intro to Maths for CS: Prime Numbers

advertisement
Intro to Maths for CS:
Prime Numbers
Joshua Knowles
School of Computer Science, University of Birmingham
Term 1, 2015-16
(Slides by John Barnden)
Textbook Part
Programme F.1, section on Factors and Prime Numbers
Prime numbers and related topics are important in many areas of Computer Science, e.g.:
in some data structuring techniques
that are usable in many different applications
in encryption as used in computer security
Barnden (SoCS)
Intro to Maths for CS: Factors of Numbers, and Prime Numbers
Term 1, 2014–15
2/7
Introduction
It’s all about NATURAL NUMBERS (non-negative whole numbers):
0, 1, 2, 3, 4, ..., 9398471094762, ...
In fact we’ll usually not be dealing with zero.
We say one non-zero natural number a divides another natural number b, written a|b,
when “a goes into b exactly,” i.e.:
there is a natural number c such that:
b = ac
So we’re talking about exact division: the remainder is zero.
Some particular cases:
1|b for any natural number b.
a|a for any non-zero natural number a.
6|42
It’s not the case that 6|43.
It’s not the case that 42|6.
Barnden (SoCS)
Intro to Maths for CS: Factors of Numbers, and Prime Numbers
Term 1, 2014–15
3/7
Factors
A (non-zero) natural number a is factor of a (non-zero) natural number b just when a|b.
So “divides” and “is a factor of” mean essentially the same thing.
The
The
The
The
factors of 12 are 1, 2, 3, 4, 6, 12.
factors of 13 are 1, 13.
factors of 130 are 1, 2, 5, 10, 13, 26, 65, 130.
only factor of 1 is 1.
A factorization of a non-zero natural number n is a way of expressing n as a product of
natural numbers.
E.g., one factorization of 12 is 2 × 6. Another is 3 × 4. Another is 3 × 2 × 2.
(For technical reasons needed later we regard a number all by itself as a product. So 12
is technically a factorization of 12.)
We don’t care about the order: 3 × 2 × 2 is the same factorization as 2 × 3 × 2.
We can collect repeated factors by using powers:
One factorization of 48 is 3 × 42 .
Barnden (SoCS)
Intro to Maths for CS: Factors of Numbers, and Prime Numbers
Term 1, 2014–15
4/7
Prime Numbers
A prime number is a natural number bigger than 1 whose only factors are itself and 1.
Examples of prime numbers:
2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 101, 277
A composite number is a natural number bigger than 1 that is not prime.
Examples of composite numbers:
4, 6, 8, 9, 15, 747
Question: Is 91 prime or composite?
Barnden (SoCS)
Intro to Maths for CS: Factors of Numbers, and Prime Numbers
Term 1, 2014–15
5/7
Prime Factorizations
A prime factor of a natural number n is a factor that is prime.
So the prime factors of 130 are 2, 5 and 13.
And the prime factors of 1300 are 2, 5 and 13.
A prime factorization of a natural number n is a factorization where every factor involved
is prime.
It can be shown that every natural number above 1 has exactly one prime factorization.
Examples:
2
5
6
9
12
100
600
Barnden (SoCS)
=
=
=
=
=
=
=
2
5
2×3
32
22 × 3
22 × 52
23 × 3 × 52
Intro to Maths for CS: Factors of Numbers, and Prime Numbers
Term 1, 2014–15
6/7
ASIDE: Goldbach’s Conjecture
A fascinating thing that looks as though it’s a fact, though it hasn’t been proven yet:
Any even number above 2 is the sum of two primes (not necessarily different).
E.g.:
4
=2+2
24
= 11 + 13
100
= 97 + 3
= 7 + 17
= 5 + 19
= 71 + 29.
If you’re interested, try to show the following (they’re easy if you’re at all into maths),
assuming the truth of Goldbach’s Conjecture if necessary:
(a) It’s not the case that any odd number above 3 is the sum of two primes.
(b) In fact, there are infinitely many odd numbers that are not the sum of two primes.
(c) Any odd number above 5 is the sum of three primes (not necessarily different).
Barnden (SoCS)
Intro to Maths for CS: Factors of Numbers, and Prime Numbers
Term 1, 2014–15
7/7
Download