Download Basic Number Theory, Lecture Notes - Computer Science and more Study notes Algorithms and Programming in PDF only on Docsity!
Basic Number Theory
Zeph Grunschlag
Announcement
Last 4 problems will be added tonight to
HW4.
Importance of Number Theory
Before the dawn of computers, many viewed
number theory as last bastion of “pure math” which could not be useful and must be enjoyed only for its aesthetic beauty.
No longer the case. Number theory is crucial for
encryption algorithms. Of utmost importance to everyone from Bill Gates, to the CIA, to Osama Bin Laden.
E.G., of great importance in COMS 4180 “Network
Security”.
Importance of Number Theory
The encryption algorithms depend heavily
on modular arithmetic. We need to
develop various machinery (notations and
techniques) for manipulating numbers
before can describe algorithms in a
natural fashion.
First we start with divisors.
Divisors.
Examples
Q: Which of the following is true?
- 77 | 7
- 7 | 77
- 24 | 24
- 0 | 24
- 24 | 0
Divisors.
Examples
A:
- 77 | 7: false bigger number can’t
divide smaller positive number
- 7 | 77: true because 77 = 7 · 11
- 24 | 24: true because 24 = 24 · 1
- 0 | 24: false, only 0 is divisible by 0
- 24 | 0: true, 0 is divisible by every
number (0 = 24 · 0)
Formula for Number of
Multiples up to given n
A: Just list them:
Therefore the answer is 6.
Q: How many positive multiples of 15 are
less than 1,000,000?
Formula for Number of
Multiples up to Given n
A: Listing is too much of a hassle. Since 1 out of 15 numbers is a multiple of 15, if 1,000,000 were were divisible by 15, answer would be exactly 1,000,000/15. However, since 1,000,000 isn’t divisible by 15, need to round down to the highest multiple of 15 less than 1,000,000 so answer is 1,000,000/15.
In general: The number of d-multiples less
than N is given by:
|{m Z +^ | d |m and m N }| = N/d
Divisor Theorem.
Proof of no. 2
In general, such statements are proved by starting from the definitions and manipulating to get the desired results.
EG. Proof of no. 2 (a|b a|bc ):
Suppose a|b. By definition, there is a number
m such that b = am. Multiply both sides by
c to get bc = amc = a (mc ). Consequently,
bc has been expressed as a times the
integer mc so by definition of “|”, a|bc •
Prime Numbers
DEF: A number n 2 prime if it is only
divisible by 1 and itself. A number n 2 which isn’t prime is called composite.
Q: Which of the following are prime?
Fundamental Theorem of
Arithmetic
THM: Any number n 2 is expressible as
as a unique product of 1 or more prime
numbers.
Note: prime numbers are considered to be
“products” of 1 prime.
We’ll need induction and some more
number theory tools to prove this.
Q: Express each of the following number
as a product of primes: 22, 100, 12, 17
Fundamental Theorem of
Arithmetic
A: 22 = 2·11, 100 = 2· 2 · 5 ·5,
Convention: Want 1 to also be expressible as a product of primes. To do this we define 1 to be the “empty product”. Just as the sum of nothing is by convention 0, the product of nothing is by convention 1.
Unique factorization of 1 is the factorization that uses no prime numbers at all.
Primality Testing
A: Assuming divisibility testing is a basic
operation – so O (1) (this is an invalid assumption)– then above primality testing algorithm is O (n).
Q: What is the running time in terms of
the input size k?
Primality Testing
A: Consider n = 1,000,000. The input
size is k = 7 because n was described
using only 7 digits. In general we have
n = O (10^ k^ ). Therefore, running time is O (10^ k^ ). REALLY HORRIBLE!
Q: Can we improve algorithm?