Divisibility

If divides , we show this as . Note that this does not mean is defined, but rather means that for some integer . This allows to be 0 too.

  • is always true.
  • is false, unless too.
  • is a fancy way of saying is even.

Question: Show that for any .

We can prove with the argument that one of those terms is even and another is divisible by 3. However, there is a better argument. We can consider the binomial , which is the number of ways to choose 3 elements from values. This gives to choose 3 elements, and they can be ordered in 6 different ways so we divide by 6. Since we are counting the choices here, the result is definitely an integer. As such, 6 divides .

Question: Show that if is odd.

Rewrite as as it is odd. Now, . 4 is there alright, and if we can show that is even then the whole thing is divisible by 8. Well, rewrite that as and one of those is definitely even.

Definition: Set of such that is called ideal. For the integers (), ideal means "closed under + and -".

Euclid's Division Algorithm

Suppose we have integers . Then Euclid treats this as and we call the quotient, and the remainder. Key point: .

forms an Ideal (closed under +, -). The converse is also true, suppose that is ideal. Then, is the set of multiples of some .

Suppose has some (if not, then ). Pick the smallest . Suppose . Then, and . Now, because the Ideal was closed under addition and subtraction.

Since is the smallest element, this implies . So, and thus is the multiples of .

So, we applied Euclid's Division Algorithm to show that ideals of integers are exactly the same of multiples of some particular element.

Greatest Common Divisor

For , the greatest common divisor is the largest integer such that and .

  • If then there is no largest integer that divides both. For conventional reasons, we set .
  • To indicate GCD in elementary number theory, people sometimes use as the notation.
  • even if .

Naïve: How do we find the GCD? The naïve method is to check all numbers up to the smallest of the two, and find the first one that divides both. However, this is really slow.

We want a fast algorithm. By fast, we kind of mean that it takes a reasonable amount of time even if the numbers have hundreds of digits (there are more technical definitions).

Better: We can factor into primes. The GCD can be found by looking at the common prime factors (up to order). For example, and . Taking the maximum common factors in both, we get .

This is cool, but factoring large numbers is hard. So we are still not that efficient.

Cool: Euclid's Algorithm is very efficient. This is probably the oldest mathematical algorithm still in use. We will describe with an example.

We are given 78 and 14. We will do division with remainder, until the remainder is 0:

The answer is the latest quotient: 2. Note that we know this algorithm will terminate for sure, because the remainder gets smaller on each step. The algorithm kind of looks at the GCD as follows: . This comes from the fact that .

How fast is this method? Let us consider the worst case. We look at , and we want small . The worst case is when . For example, .

  • aaand we are done!

We notice that we can work our way up backwards, the remainders follow the recursive pattern for this example. Looks familiar?

Fibonacci Sequence

This sequence 0, 1, 1, 2, 3, 5, is the Fibonacci numbers. is the Fibonacci number, and the worst case of Euclid's algorithm is when we are finding .

Let us find out how fast does Fibonacci grows.

  • _Lower: 0, 1, 1, 2, 2, 4, 4, 8, 8, ...
  • Actual: 0, 1, 1, 2, 3, 5, 8, 13, 21, ...
  • ^Upper: 0, 1, 2, 4, 8, 16, 32, 64, 128, ...

This gives us the growths . In particular, we see that for some constant , and is the number of steps in Euclid's algorithm.

So, the number of steps of Euclid's algorithm which is approximately .

Is there a formula to find for ? This is an example of "Finite Difference" equation by the way. Note that "General Finite Difference" equations have the form:

for constants

The method to solve these equations is to literally guess the answer. That doesn't sound cool, so instead we say you find the ansatz (which means guess).

With ansatz we guess the form of the answer with some unknown coefficients. You could take a guess like , or perhaps for some constant . The constants should also be guessed in those. The latter guess seems to work quite nicely for Finite Difference equations.

Looking at , we have . So, . The solutions are . Hmm, that's not cool because those are not integers. But we do not give up. What if the answer is a linear combination of these solutions?

Now we will try to adjust to get the Fibonacci numbers. Thankfully, we know and . This gives us:

We thus find and . So,

Fibonacci numbers have quite a lot of cool and funny properties (proofs left as exercise):

  • is always a square.
  • .

The number is known as the Golden Ratio (shown as or sometimes).

Euclid's Algorithm to Solve Equations

Suppose we know and the problem is to solve . We can solve by using the same algorithm described in the previous section. For example, lets find . We first find the GCD:

The GCD is 1. Now we work our way backwards:

Et voila! We found , so and .

Note that is solvable if and only if . We can find the solution for and the just multiply the findings to reach . Also note that once you find , other solutions are possible such as . What about linear equations in 3 variables? Such as:

Well, we can solve two at a time, referring to (since ), giving us and . Then, we find (since ). There we find and .

Done! and .

Again, we can only solve if and only if . This actually works for an arbitrary number of variables!

The problem with Euclid's Algorithm is that it is using "long division", which is slow and complicated. For large numbers, computers don't really know how to do it, and you have to program it yourself. Even Intel got it wrong back in the day.

Long Division

We can avoid long division by being a bit more clever, and doing divisions by two only (which is really fast on computers). To solve we do as follows:

  1. Take out all factors of 2 from and . And now assume that and both are odd.
  2. Change to . Now has to be even.
  3. If the result is 0, stop.
  4. Otherwise, take out the factors of 2, and go back to step 2.

Least Common Multiple

Given and , the least common multiple is the smallest number divisible by and , and is less than or equal to . For example, . It turns out that:

This is actually a bit obvious when we look at the factors.

Now notice that . Therefore, .

Primality Tests

A prime is an integer not divisible by anything except and . 1 is not a prime, because it is defined that way and it is very convenient to define it that way (although not everyone agree with them).

Alternatively, we could allow negative integers too such as . In that case: a prime is an integer such that if then or is a unit. A unit is something that has an inverse, and the only units for integers are and .

A naïve method would check if a number is divisible by anything smaller than itself . It is very inefficient. We speed up this by:

  • Checking only primes in the division
  • Checking up to

As such, the number of steps for this method would be . Even then, this is too slow if is large (like 100 digits or something).

For very large methods, you could first check if it is divisible for some small primes, and then go on to the more advanced test methods.

Fundamental Theorem of Arithmetic

Any number is a product of primes in a unique way up to order. Note that is a product of the empty set of primes (this is a nice convention).

Alternatively, allowing negative integers: any number is a product of primes and a unit (1 or -1) in a unique way up to order and then up to units.

Proof: We have two parts: an easy part for existence, and hard part for the uniqueness.

  1. Easy part (Existence): Take . If or is prime, then we are done. Otherwise where .

    So by induction, is a product of primes and is a product of primes and thus is a product of primes .

  2. Hard part (Uniqueness): Suppose is prime, and . Then, or . This is the central key result in order for this proof to work.

    Suppose , then as is prime. By Euclid, for some integers . Now multiply by to obtain . Well, divides and also divides , therefore divides (right-hand side).

    Now lets suppose . Then . So, for some , but is prime, so . You can repeat this by diving all the newly found . So, the factorization is unique up to order.

We can also give a similar result for polynomials over . Take . Here, the units are non-zero constant polynomials, and every non-zero polynomial can be written as a product of irreducible polynomials and constant polynomials.

Real numbers don't have primes, because any real can be written as

What about integers in the form , such as ? Well, you indeed have "primes" where the product is like . However, the factorization is not unique, e.g. .

Both examples (reals and number 1 mod 4) were not closed under addition and subtraction. Maybe that was the cause of non-uniqueness? Well, lets see one example that is closed!

Lets look at functions on reals . We can multiply, add or subtract them point-wise. Well, turns out we can't write functions as a product of "prime" functions, for example:

  • it goes on like that, and none of them are units.

Another example: take all numbers of the form where are integers. This is an example of algebraic number field. Well, this is not unique too, .

We will later see that number of the form have unique factorization! These are called Gaussian Integers. Units here are

Euclid's Proof of Infinitude of Primes

We have shown this in the first lecture. In three lines:

  • , so is a new prime.

Note that is not necessarily a prime! Thinking that this is the case is a common mistake.

Here is a cool question: suppose you find the primes following the proof described above (so you take in every step). You will get and such. Do all primes appear? We do not know, and it is very hard to check this, but it is almost certainly yes!

Suppose we take some prime, does 101 appear? Well, almost certainly yes! The change that it appears at step is . This is because we are dividing a number by 101 (so that ), which is possible every 101 numbers over integers.

So, the chance that it does not appear at step is . The chance it does not appear at step is . If you take a very large , this approaches 0. I really liked this proof!

Nevertheless, proving that all primes are given seems to be really hard. We have just no idea how to prove it.

Last Digit

We know that the last digit of primes should be 1, 3, 7 or 9 (other than 2 and 5 for their respective numbers). We may ask, are there infinitely many primes with the last digit 1, i.e. primes of form ? Dirichlet proved that yes, indeed there are!

Well, are there infinitely primes in the form where and ? Dirichlet's proof on arithmetic progressions actually prove that yes, there are infinitely many primes in all arithmetic progressions.

Let us check some easy cases. Take primes of form . Well, you could do a variation of Euclid's proof. Take number . This number is indeed of form , and:

  • It is not divisible by any of the .
  • It must have at least one factor that is not of form . This is because product of primes of that form result in too, so one prime must be of form for the result to be of form
  • Consequently, there must be a new prime factor of form .

You could do a similar thing for primes of form .

What about ? We can't use the previous proof on this one. However, we could notice the fact: if a prime is one that then or it is of the form (proof later). Now suppose you have a number:

We have 2 in there so that the result is odd, and square so that the result is of form which a prime can divide. All primes in there were of form or . The result is obviously not 2, nor any of the existing primes. So, there must be a new prime factor of that number.

Prime Gaps

Looking at we have varying amount of gaps. Is there a bound to the gaps?

The answer turns out to be no. It is easy to show, as you can take numbers and there will be numbers that are not prime. Well, is slightly less than . Turns out that the average size of prime gap is . It is very hard to show that gap is sometimes bigger or smaller than this.

Zhang has shown that gap is sometimes less than for large , in an amazing breakthrough. It has been reduced to a few hundreds recently.

It is believed that there are infinitely many consecutive primes with gap 2. It is also conjectured that the gap is sometimes . This seems to be very hard to prove.

Another crazy result by Rankin (1938) shows that the gap is sometimes bigger than:

Bizarre!