Lecture 2: An Introduction to Number Theory

In this lecture, we are going to discuss the first properties in the field of number theory. These are essential for our continued study of cryptology. We can do little more without some basic definitions and results. Whenever possible, examples will be used to illustrate the ideas. The hope is that this brief introduction inspires the reader to study this beautiful field more thoroughly.

Prime Numbers

A positive integer is called a prime number if it is divisible only by one and itself. Primes form the building blocks of all numbers because of the following theorem.

Theorem [Fundamental Theorem of Arithmetic]: Every positive integer is uniquely a product of prime numbers.

Of course, given a number , a prime can appear on its list more than once. For instance, the number

Much later on, we will see that factoring a number into its prime factors is extremely difficult and plays an important role in cryptology. But first, we continue to study our prime numbers.

We know that there are infinitely many numbers. And we know that each can be written uniquely as a product of primes. So it seems that there must be quite a few prime numbers. However, is it possible that only finitely many prime numbers could generate all of the numbers? The answer to this question goes back to Euclid.

Theorem: There are infinitely many prime numbers.

Proof: Suppose that there were only finitely many prime numbers. Then, we could write them all down in a list, . Consider now the number

It is necessarily larger than any of the primes on our list, and so therefore is not prime. But, from the Fundamental Theorem of Arithmetic, it has a prime factorization. This means, in particular, that it is divisible by one of the primes on our list. This cannot be the case however, since our number divided by any prime on our list give remainder 1. Thus, our list is incomplete and there are infinitely many primes.

Greatest Common Divisors

Let and . be positive integers. By the Fundamental Theorem of Arithmetic, both and have factorizations into products of prime numbers. We would like a way to measure how much the factorizations overlap. Fortunately, this is easy. The greatest common divisor of and (or ) is largest positive integer such that divides both and .

For example, . We will see in a moment that greatest common divisors exist for any two positive integers and . If and are such that , then we say that and are relatively prime. For example, 8 and 15 are relatively prime. This terminology comes from the fact that they have no common proper divisor other than 1; much like how a prime number has no proper divisor other than 1.

In particular, if is prime, then we know that is a divisor of for any . Thus we have that . The latter case only occurs when is a multiple of .

Proposition: Given two positive integers and , exists and is unique.

As we mentioned above, factorization is a very difficult process, so while the above proof shows how to construct the greatest common divisor, it is not very efficient. In the next section, we will discuss an algorithm which works much better.

The Division Algorithm

Given two positive integers , we can do grade school long division to find a quotient and a remainder so that we can write

``''.

Reversing this procedure shows that . Moreover, the long division makes sure that , so that and we find are unique. Amazingly, this is all we need to do to find .

Algorithm[The Division Algorithm]: Let be positive integers.

  1. Find and with such that .
  2. Find and with such that .
  3. Find and with such that .
  4. Repeat Step 3, dividing by until you have a remainder of zero (i.e. until you get to the first such that ).
Then, for the where Step 4 stops, we have that .

Let's find . We follow the algorithm exactly:

Since , we see that . Indeed, one can also check that and .

Modular Arithmetic

Recall from the last lecture that when we were assigning numbers to represent letters or symbols, we had to 'wrap around' once we got to the end. Accordingly, when we used the shift cipher, sometimes we had to subtract off to make sure that our ciphertext actually made sense. This is idea behind modular arithmetic: we fix a number , the modulus, and do arithmetic 'wrapping around' whenever we get bigger than .

Fix our modulus to be 38. Then if we want to compute 19+25 'wrapping around' 38, we simply find 19+25=44. Since 44>38, we need to subtract: 44-38=6. Thus, 19+25=6 'wrapped around' 38. Other operations work as well:

Let's now rigorously define how to do modular arithmetic, so that we no longer need to write 'wrapped around' each time we use it! Fix a positive integer . Then we will say integers and are congruent modulo if divides . In this case, we write . We now state a theorem which explains how usual arithmetic behaves modulo .

Theorem: Let be a positive integer, and let , , and be any integers.

  1. If , then .
  2. If and , then .
  3. If , then .
  4. If , then .
  5. If , then .
  6. If and is relatively prime to , then .
Let's re-work the previous example in our new notation.

Fix

Now, let's go over a few tips for actually doing modular arithmetic. First, if we are working modulo , then every number must be congruent to one of , and none of these numbers are congruent modulo (why?). Thus, we can automatically reduce any number to something less than our modulus. For example, if we are working modulo 42, we can think of 156 as 30. Or, putting it in notation, . Off the bat, this may not seem like much of a difference, but the above theorem shows that you can either do modular arithmetic first and then reduce or reduce first and then do modular arithmetic. Either way will give you the same answer! In general, it is faster to reduce first, because it makes the numbers smaller. Let's do some examples.

These are chosen to illustrate why one should reduce first, and then do the arithmetic.

  1. Find . Well, and , so . Alternatively, and or and . Thus, . But and , so . In this case, it was one extra step to reduce first, but it kept the numbers we worked with smaller.
  2. Find . First we will do it directly: and . Thus, . Of course, we could have reduced first: and so that . Since and we get again that . We needed an extra step reducing first here also, but doing so made it so all of the arithmetic was easily done in one's head. Without reducing first, at the minimum there was some serious paper and pencil calculation.
  3. Compute . In this case, it would be much too difficult to try this directly, even with a calculator. So our only hope is to reduce 281 modulo 23 first. Well, so that . Thus, we know that . Now, we have two options. We can either use a calculator and compute , or we can continue to reduce modulo 23. Let's follow the second, since the first is fairly straight forward.

    How do we reduce modulo 23? Notice that . Thus, if we write

    we can see that

    Now we work the same trick again. Since , we have that . Since , we can rewrite this as . We notice, however, that . Thus, we are left with . Now, and . Thus we conclude that (Phew!).

Exercises

  1. If any of part of this section was unclear, head to the references section and find an introductory book on number theory. Read it. Do the exercises.
  2. Pick two two-digit numbers. Find their greatest common divisor. Pick two three-digit numbers. Find their greatest common divisor. Pick one three-digit number and one five-digit number. Find their greatest common divisor. Repeat this as many times as it takes until you are comfortable finding greatest common divisors.
  3. Do the following modular arithmetic:



This work was made possible through a grant from the National Science Foundation.