Recall Fermat’s Theorem from the lecture 09
There is another important definition that we also need as follows
For example, take \(p = 7\), then
What about negative powers of \(a\)? What is \(a^{-n}\)? well this is just \((a^{-1})^n\). So when can we find the inverse of \(a\)? We know that the inverse of \(a\) will exist only if \((a,p)=1\). This is because we’re trying to solve
This is just \(ax = 1 + py\) and this has a solution if \((a,p) = 1\) by Euclid’s algorithm.
Properties of the order of \(a \bmod p\)
Suppose now that \(p\) is prime and \(n > 0\). We have two very important results:
Proof: Let’s look at all the possible integers \(n\) that satisfies this. So consider the set
\(S\) is closed under the addition and subtraction of the exponents since if \(a^m \equiv 1 \bmod p\) and \(a^n \equiv 1 \bmod p\),
Therefore, \(S\) is an ideal. But we know that any ideal in \(\mathbb{Z}\) is a principle ideal so there has to be some smallest integer such that all of these integers are multiples of it. In other words,
Therefore, \(d\) is the order of \(a \bmod p\) and for any \(n \in S\), we have \(n = kd\) for some \(k \in \mathbb{Z}\). Thus, \(d \mid n\) such that \(a^n \equiv 1 \bmod p\). \(\ \blacksquare\)
The second result is
Proof: So we already established that \(d\) divides any \(n\) such that \(a^n \equiv 1 \bmod p\). Now observe that by Fermat’s theorem
So this means that \(d\) or the order of \(a\) divides \(p-1\).
Application
One application of this is the following theorem
Proof
So we know that \(p\) divides \(2^q - 1\). This means that
Therefore, the order of \(2\) must divide \(q\) by the previous result. But \(q\) is prime so the order of \(2\) can either be 1 or \(q\). However, it can’t be 1 since \(2 \not\equiv 1 \bmod p\). So the order of 2 must be \(q\). But we also showed using Fermat’s theorem that the order must also divide \(p-1\). Therefore, \(q\) divides \(p - 1\). But this just means
as we wanted to show. \(\ \blacksquare\)
Example
One way to do this, is to iterate through all primes less than \(\sqrt{2^{13}} = \sqrt{8191} = 91\) and see if they divide \(2^{13}\). This works but there is a faster way. We can use the previous theorem we just proved where if \(p\) and \(q\) are primes and \(p\) divides \(2^q - 1\), then \(p \equiv 1 \bmod q\). So if \(p \mid 2^{13} - 1\), then this means
Only two primes under \(\sqrt{8191} = 91\) satisfy this equation. \(p = 53\) and \(p = 79\). So just need to check that that neither divide \(2^13 = 8191\) and neither does! \(\blacksquare\)
Fermat Primes
Recall that Fermat Primes are of the form \(2^n + 1\). Also recall that if \(n\) has an odd factor, then \(2^n+1\) is not prime. The reason for this is that \(x^{2n+1}+1\) is divisible by \(x+1\) since
In general if \(n = ab\) with \(a\) odd. Then,
\((2^b)^a + 1\) is divisible by \(2^b + 1\). So for \(2^n + 1\) to be prime, \(n\) needs to be a power of 2. For example, the following are Fermat primes
So now we want check the following
As before, we can check all the primes up to \(\sqrt{2^{n} + 1}\). But we can use Fermat’s theorem to speed things up. How? Suppose \(p\) divides \(2^{2^n} + 1\). This just means that
Squaring both sides
So now, let \(d\) be the order of \(2 \mod p\). \(d\) must divide \(2^{n+1}\) so \(d\) must be some power of 2 less than \(2^{n+1}\) so
At the same time, \(d\) is the smallest power such that \(2^d \equiv 1 \bmod p\) and we also know that
So \(d\) can’t divide \(2^n\). Why? Suppose it did, then we can write \(2^n = d \cdot m\). Then
But \(d\) is the order of 2 so
This is a contradiction since \(2^{2^n} \equiv -1 \bmod p\). So \(d\) must be exactly \(2^{2^{n+1}}\). Also by Fermat, we know that
This is because \((2,p) = 1\) and \(p\) is prime. Therefore, \(d = 2^{n+1}\) divides \(p-1\). This means that
This is a strong condition that the prime factors must satisfy. For example, take
If \(p \mid 65537\), then
and if
Then \(p \not\mid 65537\). So we only want to check any prime \(p\) less than \(\sqrt{65537} < 257\) such that \(p \equiv 1 \bmod 32\). If we look at any number that satisfies \(p \equiv 1 \bmod 32\), then we get
Some of these are obviously not prime, we only need to check
So now we can just use long division to verify that 65537 is prime. Neither of these divide 65537 so 65537 is prime.
Example
Euler proved that this is not a prime. Using the condition we proved earlier, suppose that \(p \mid 2^{2^5} + 1\). This means that
So the numbers that satisfy this are
We can cross the numbers divisible by 5 or 3 and get
What Euler discovered is that \(641 \mid 2^{2^5} + 1\). How do we check that 641 divides \(2^{2^5} + 1\)? An easy way is see that
So now
The idea is to take modulo 641 at every step to avoid large calculations.
Example
The answer is no. Suppose \(m = 8\). Then,
But
It does work if \(m\) is prime. Why? Observe that
Because \(p\) is prime, then either \((a-b)\equiv 0 \bmod p\) or \((a+b) \equiv 0 \bmod p\).
Example
The answer is still no. Take primes \(p\) and \(q\) and let \(m = pq\). Now suppose
But these two imply that
We can combine both to get
The claim is that
Why? suppose for the sake of contradiction that \(a \equiv \pm b \bmod m=pq\). Specifically suppose that
Since \((p,q) = 1\), then
but now recall that we also have \(a \equiv b \bmod p^2\) so
This is a contradiction. We can’t have both \(a \equiv b \bmod p\) and \(a \equiv -b \bmod p\) at the same time. Similarly, we can arrive at a contradiction if \(a \equiv b \bmod pq\) by using the other assumption that \(a \equiv -b \bmod q^2\). \(\ \blacksquare\)