Divisibility and Primes

Sets and Closure

A set is an unordered collection of distinct mathematical objects.
Sets can be denoted by , where is a set and and are elements of the set .

To represent membership, we use , stating that is in . Therefore, we can say that read as " is an element of ".

A subset is a set whose elements are also all elements of another set; denoted as . We can say that as is a set containing the element .

Some examples of special sets include:

called the set of natural numbers, which are all whole numbers from zero onwards. It is important to remember that the naturals contains 0.
Another set can be the set of integers,

which is the set of naturals with the inclusion of the negative numbers.
You can also restrict sets with rules, such as:

which is the set of positive integers, (notice the sign).
Another set can be the rational numbers,

where is any integer, and is a positive integer, representing any number that is a fraction.
Furthermore, there is the set of the reals,

which includes irrational numbers such as or .
And finally, there is the set of the complex numbers,

Note:

Pasted image 20260603112505.png

A set is said to be closed under addition if for any , .
This means that addition between any two elements within a set must also result in an element in that same set:

Each of the sets that we've looked at so far are closed under addition.

A set is said to be closed under multiplication if for any ;

Each of the sets that we've looked at so far are also closed under multiplication.

Example. A set is said to be closed under subtraction if, given any , we have that .
Decide whether each of the following sets is closed under subtraction.

Closed under subtraction Not closed
The reason and :

Example. Decide whether each of the following sets is closed under division (excluding division by ): .
None of or are closed under division;

On the other hand, and are closed under division; dividing by any non-zero element keeps you in the set. For example, given with ,

which is still a ratio of integers with a non-zero denominator; i.e. still rational. Therefore, and are closed under division, whilst and are not.

This failure of closure is basically the reason Number Theory exists; since dividing one integer by another is not guaranteed to give an integer, the special cases where it does are worth studying in their own right. That is exactly the idea of divisibility.

Divisibility

Given two integers and , we say that divides if we can write , for some integer . This can also be represented by

Notice that the first statement requires at least one integer , whilst the second requires it to be false for any integer .

If , we can equivalently say that is a divisor of , is a factor of , is divisible by , or is a multiple of ; these all mean exactly the same thing, so don't get thrown off if a question uses one phrasing over another.

Example. Decide whether the following statements are true or false.

Notice how the order matters ( but ), and how divisors are perfectly allowed to be negative; just has to be some integer.

Example. Is it true that ?
Using our definition, in order for it to be true, we would need to be able to find an integer such that is equal to times ;

However, the right hand side here is always going to be equal to zero regardless of , therefore
.

Example. Is it true that ?
Using our definition again, we need to find an integer such that 0 is equal to 3 times ,

we can see here that setting , we see that the statement is true. Therefore, .

Regarding 0, is it true that ?
It is indeed true; every number divides 0, including 0 itself.

Example. For which integers is it true that ?
By the definition, requires an integer with

So the only integer that divides is itself. Therefore, if and only if .

Be careful not to mix up the two directions: every integer divides , but divides nothing except .

Note

Lemma 1.1
For all integers , we have that . That is, is reflexive.
Since and , taking in the definition immediately gives .

Note

Lemma 1.2
For all integers if and , then . That is, is transitive.
We are given that and , for some , we can rewrite to get ; .
Since , we conclude that .

Note

Lemma 1.3
For all integers , if and , then for any .
By definition, and , for some .
Given any integers ,

Since , we can conclude that .

A couple of handy facts fall straight out of these lemmas:

  • for any integer ; take and in Lemma 1.3.
  • If , then for any integer ; take and .

Basically, once divides something, it also divides every multiple of that thing, and every "integer combination" of things it already divides. Lemma 1.3 is the real workhorse of this topic; most divisibility proofs boil down to writing your target as for clever choices of and .

Example. Suppose that is a positive integer such that and for some integer . Show that .
The trick is to use Lemma 1.3 to eliminate . Choosing and ,

The only positive integer dividing is itself. Therefore, .

Example. Prove that for all .
This is a classic induction + divisibility combo; whenever the sits in an exponent, induction is usually the way to go.
Let be the statement "".
Base case: states that , i.e. , which is true since every integer divides .
Inductive step: suppose that holds, i.e. . Then,

Since (inductive hypothesis) and (reflexivity), Lemma 1.3 with tells us that ; that is, . Hence , and by induction for all .

Example. Prove that for all integers , if then .
Proving this directly is awkward, because "" gives us no equation to work with. Instead, we prove the contrapositive, which is logically equivalent:

Proof. Suppose that , so for some . Then,

Since , we have ; this proves the contrapositive, and hence the original statement.
When a divisibility statement starts with "does not divide", try the contrapositive first; it turns into , which hands you an actual equation like to substitute.

Primes

Uhm this is self explanatory so I'm not gonna write much;

A prime is defined as a number in such that it is not , and it's only divisors are and the number itself.

A composite is a number in that is not or a prime.

More formally, the lecture defines primes via irreducibility:

Note

Definition
An irreducible number (or irreducible element of ) is any such that both

  • is not or , and
  • the only divisors of in are and .

A prime number (or just a prime) is an irreducible number.

Note

Definition
An irreducible integer (or irreducible element of ) is any such that both

  • is not , , or , and
  • the only divisors of in are , , , and .

A prime integer is an irreducible integer, and a composite integer is any integer that is not , , , or a prime integer.

Basically, a prime refuses to factorise; the only way to write it as a product of integers is the boring way, times itself. The first few prime numbers are , but notice that over the prime integers also include the negatives , and likewise the composite integers include . The numbers and are deliberately excluded from both camps (what makes them so special gets explored later in the course, in Lectures 2.3, 3.2 and 7.1).

Note

Theorem
Suppose that and are integers and is a prime integer.
If , then or .
Note: can divide both and ; they are not exclusive.

Basically, a prime cannot be "split" across a product; if it divides the whole thing, it must divide at least one of the pieces. This property is actually how prime elements are defined in general (the proof is in Lecture 1.3).

It is important to note that this property fails for composite numbers. For example, (since ), yet and ; the got split into a (hiding inside the ) and a (hiding inside the ). That can only happen because is composite.

Example. Suppose that is prime and for some integer . Show that .
Since , applying the theorem with gives

which is just . Therefore, ; a prime dividing a perfect square must divide the base. (This is the key step in the classic proof that is irrational.)

Example. Prove that for all integers .
First, factorise;

which is a product of three consecutive integers. Out of any two consecutive integers one must be even, so ; out of any three consecutive integers one must be a multiple of , so .
Now we combine the two. Write for some . Since and is prime, the prime divisor theorem says that or ; clearly , so , i.e. for some . Hence,

Therefore, for every integer .
Notice how " and , therefore " needed an actual argument; you cannot just multiply divisors together in general ( and , but ). It only worked here because one of the divisors was a prime not dividing the other.

Example. Suppose where is prime and is an integer. Prove that .
Suppose, for contradiction, that and . By Lemma 1.3 with ,

But the only divisors of are , and a prime is not ; contradiction. Therefore, . In other words, consecutive integers never share a prime factor — keep this in your back pocket, it is exactly the trick that powers Euclid's proof below.

Mersenne primes are primes of the form where is prime.

Fermat primes are primes of the form where is a natural number.

Twin prime pairs are pairs of primes that differ from each other by 2, such as or

Sophie Germain primes are primes for which is also prime, such as
(since 7 is prime) or (since 107 is prime).

For such a fundamental object, surprisingly little is actually known about primes; it is still an open problem whether there are infinitely many of any of the four types above. Some things we do know:

  • The largest known Mersenne prime to date is .
  • Only five Fermat primes are currently known: .
  • It was shown in 2018 (Maynard, Tao, Zhang, et al.) that there are infinitely many pairs of primes that differ by at most ; the largest known twin prime pair has digits in each prime.
  • The largest known Sophie Germain pair also starts with a -digit prime.

This mystery is also useful; finding large primes is computationally hard, but doing arithmetic with them is computationally easy, and cryptography schemes are built exactly on that imbalance (more on this later in the course).

Example. We have , and is prime. Is a Mersenne prime?
No! Checking small prime divisors,

so is composite, and being composite it cannot be a Mersenne prime (or any kind of prime). A prime exponent does not guarantee that is prime; it only makes it a candidate. Compare with and , which really are Mersenne primes.

Example. Show that if is prime, then must be prime.
This explains why the Mersenne definition insists on a prime exponent in the first place. Once again the direct statement is awkward, so we prove the contrapositive: if is composite, then is composite.
Suppose that , where are integers with . Recall the factorisation ; substituting ,

Since , we have , so is a divisor of that is neither nor the number itself; hence is composite.
For instance, ; a composite exponent never even had a chance.

Example. Classify each of , and as Mersenne, Fermat, twin and/or Sophie Germain primes.
For :

It is not Mersenne, since would need , which is not a power of .
For :

It is not Fermat ( is impossible) and not Sophie Germain, since is composite.
For :

It is not Mersenne ( would need , which is not a power of ), not twin ( and are both composite) and not Sophie Germain, since is composite.
Therefore, is simultaneously Fermat, twin and Sophie Germain; is Mersenne and twin; and is only Fermat. The categories are not mutually exclusive — always check each definition separately.

Two Key Theorems about Primes

Note

Fundamental Theorem of Arithmetic
Every positive integer greater than 1 has a unique prime factorisation; any positive integer can be written uniquely in the form

where are primes such that and are positive integers for some .

Strong Induction
Involves two things,
(1). Proving a base case .
(2). Proving that if holds for all , then holds.
In other words, strong induction involves proving that every value less than is true in order to verify if is true for a given statement.
If and is true, we can use this information to confirm whether or not is true;

We now use strong induction to prove the Fundamental theorem of Arithmetic.
In order to complete our induction we simply need to confirm if for all ,

(1).
Our base case can be , since 2 is the smallest number that is itself a prime and is its own unique prime factorisation. With this, we have completed the first step.

(2).
Since our base case is 2,

Now for the choice of , we have two possibilities,

  1. is prime, meaning that it's prime factorisation is simply
  2. is composite. In this case, can be written as , where are both integers larger than 1 and less than . Since is greater than 1 and strictly less than , this means that is a part of our inductive hypothesis,

in other words, has a unique prime factorisation. is also similarly strictly between 1 and , meaning it also has a unique prime factorisation. We can combine the unique prime factorisations of and together to get the prime factorisation.

However, we haven't shown that the prime factorisation is unique, only that it exists.
Let's suppose that had two prime factorisations; it can be written in two ways:

Where each are primes. Looking at , we know that it divides , , and therefore it divides one of the terms on the RHS, . Since all of our terms give us all of the prime factors of , and is a prime factor of , this means that must be equal to one of those terms. Suppose that it is equal to , giving us

If we divide both sides by , we get

Since both statements are now smaller than but larger than , the statements are a part of our inductive hypothesis and therefore must have a unique prime factorisation, meaning that both statements are identical. Since both of the expressions are identical, we can multiply both expressions by to get , meaning that must have a unique prime factorisation.

This completes the proof.

Example. Find the prime factorisation of .
Peel off primes from smallest to largest;

Therefore, , and by the Fundamental Theorem of Arithmetic this is the only way to write as a product of primes (the condition is what pins down the ordering, so we don't count as a "different" factorisation).

Example. Use the Fundamental Theorem of Arithmetic to prove that is irrational.
Suppose, for contradiction, that for some . Squaring both sides and rearranging,

Now count how many times the prime appears on each side. By the FTA, and each have a unique prime factorisation; say appears in them with exponents and respectively (possibly ). Squaring doubles every exponent, so appears in exactly times — an even number of times — whilst it appears in exactly times — an odd number of times. But and are the same integer, so by uniqueness of the prime factorisation they must contain exactly the same number of ​s. An even number can never equal an odd number, so we have a contradiction; hence is irrational.

Basically, a perfect square must contain an even amount of every prime, and is stuck with an odd amount of ​s, so it can never be a perfect square. The exact same exponent-counting argument shows are irrational; the FTA turns questions about irrationality into questions about parity.

Note

Euclid's theorem
There are infinitely many primes.

To prove this theorem, we will use proof by contradiction.

Suppose that there are finitely many primes;

where . Consider the number

By the Fundamental Theorem of Arithmetic, there is a prime such that

as every number must have a unique prime factorisation, and since is a product of every prime, definitely divides . Since it divides both and , it must divide , or , but if , that must mean is 1. However, 1 is not a prime number, and we assumed that is a prime. This is a contradiction, and hence our original assumption was false.

Example. A common trap is to think that Euclid's construction always produces a prime. Show that this is false by considering the first six primes.

and both and are prime, so is composite. This doesn't break the proof at all; the proof only needs some prime factor of , and shows that cannot be on our supposedly complete list (since would divide both and ). Here, and are indeed both missing from , which is exactly the kind of "new prime" the argument promises.
Euclid's argument does not claim that is prime; it only claims that its prime factors are new.