Chapter
Fermat and Euler
Fermat's Little Theorem, Euler's totient function, Euler's theorem, modular inverses, and large power computations.
Theory
1. Fermat's Little Theorem
If \(p\) is prime and \(p\nmid a\), then
\[ a^{p-1}\equiv1\pmod p. \]
Equivalently, for every integer \(a\),
\[ a^p\equiv a\pmod p. \]
This theorem is a powerful way to reduce large powers modulo a prime.
2. Modular Inverses
If \(\gcd(a,m)=1\), then \(a\) has an inverse modulo \(m\). That means there is an integer \(b\) such that
\[ ab\equiv1\pmod m. \]
Fermat's theorem gives a useful inverse modulo a prime:
\[ a^{-1}\equiv a^{p-2}\pmod p. \]
3. Euler's Totient Function
Euler's totient function \(\varphi(n)\) counts the positive integers from \(1\) to \(n\) that are relatively prime to \(n\). For example,
\[ \varphi(10)=4, \]
because \(1,3,7,9\) are relatively prime to \(10\).
If
\[ n=p_1^{a_1}p_2^{a_2}\cdots p_k^{a_k}, \]
then
\[ \varphi(n)=n\left(1-\frac1{p_1}\right)\left(1-\frac1{p_2}\right)\cdots\left(1-\frac1{p_k}\right). \]
4. Euler's Theorem
If \(\gcd(a,n)=1\), then
\[ a^{\varphi(n)}\equiv1\pmod n. \]
Fermat's Little Theorem is the special case when \(n\) is prime.
5. Strategy for Large Powers
To compute \(a^k\pmod n\):
- Check whether \(\gcd(a,n)=1\).
- If yes, reduce the exponent modulo \(\varphi(n)\), or use a shorter cycle.
- If not, use direct factorisation, prime powers, or another modulus.
Examples
Example 1. Fermat Modulo Five
This is the cleanest first FLT computation.
Example 2. Fast Power Modulo Seven
Short cycles may be better than a theorem.
Example 3. Totient by Listing
Listing before formula keeps the function meaningful.
Example 4. Totient Formula
Require prime factorisation before applying the formula.
Example 5. Euler Modulo Ten
Connect Euler theorem to familiar last-digit work.
Example 6. Inverse Modulo Eleven
Do this by inspection before using Fermat's formula.
Example 7. Fermat Inverse
This is conceptually important for solving congruences.
Example 8. Euler Power
Again, short cycles are often more efficient than full Euler theorem.
Problems
Problems
Ladders