Divisibility
If n and d are integers and , then n is divisible by d iff for some integer k.
Alternate ways to say the same thing are:
Examples:
Properties of Divisibility
Claim: For all integers a, b, and c, if a divides b and b divides c, then a divides c.
Proof: By the definition of divisibility, and , for some integers r and s.
By substitution,
Since the product of two integers (r and s) is an integer, we have shown that a divides c with quotient . height6pt width4pt
Claim: For all integers a and b, if (i.e a divides b) and , then a = b.
Counterexample: and !
Mod and Div
In integer division , we get both a quotient q and a remainder r.
The quotient remainder theorem states that for any integer n and integer d > 0, in only one way where .
Why? Because .
The div function returns the quotient of integer division.
The mod function returns the remainder of integers division.
Examples:
The last two follow from the quotient remainder theorem.
Applications of Mod and Div
What day will it be next year on this date? and . Thus there are 52 full weeks and 1 day in a year, so we add one to the day of the week to get the day of the week next year.
Thus Thursday October 8, 1998 implies Friday October 8, 1999.
What about a leap year?
for integer constants a, b, and m.
For example, if we use the constants:
and start with , we generate
By picking the right constants, we get numbers which look like they are random.
Prime Numbers
An integer n is prime iff n > 1 and for all positive integers r and s such that , then r=1 or s=1.
n is prime positive integers r, s, or (s=1).
Note that 1 is, by definition, not prime.
An integer n is composite iff n > 1 and there exist positive integers r>1 and s>1, .
The Unique Factorization Theorem or Fundamental Theorem of Arithmetic states that any integer n > 1 can be written uniquely as the product of prime numbers.
Examples:
How Many Prime Numbers are There?
Primes are integers which have no non-trivial factors.
It seems like it should get harder and harder for large numbers to be primes, since any prime number less than n is a potential factor.
Certainly, prime numbers tend to get rarer and rarer as n gets larger.
There are 168 primes less than 1000, but only 135 primes from 1000 to 2000. There are 5133 primes less than 50,000, but only 4459 from 50,000 to 100,000.
Do the prime numbers eventually become so rare that we run out of them? Or are there an infinite number of primes?
Euclid's Proof
Euclid showed that there are an infinite number of prime numbers using an elegant proof by contradiction.
Every educated person should know Euclid's proof!
Assume the converse, that there are only a finite number of primes, .
Let , i.e. the product of all of these primes, plus one.
Since this is bigger than any of the primes on our list, m must be composite. Therefore some prime must divide it.
But which prime? m is not divisible by , because it leaves a remainder of 1. m is not divisible by , because it leaves a remainder of 1. In fact, m leaves a remainder of 1 when divided by any prime , for .
Thus cannot be the complete list of primes, because m must therefore also be prime.
Since this contradicts the assumption that there is a complete list of primes, it means there cannot be a complete list; i.e. the number of primes is infinite!
Question: Suppose we take the first n primes, multiply them together, and add one. Does this number have to be prime?
Counterexample: We should expect it to be easier to find a counterexample for larger numbers, since primes are rarer and there is more room for for other prime factors.