Sign in to save

Bookmark this page so you can find it later.

Sign in to save

Bookmark this page so you can find it later.

Fermat's Little Theorem is a key result in number theory that helps simplify powers in modular arithmetic. This cheat sheet covers the theorem, when it applies, and how it is used to find remainders and modular inverses. Students need it because large exponent problems become manageable when powers repeat in predictable cycles.

It is especially useful for contest math, cryptography basics, and advanced algebra topics.

The main idea is that if pp is prime and aa is not divisible by pp, then ap11(modp)a^{p-1} \equiv 1 \pmod{p}. This means exponents can often be reduced modulo p1p-1 when working mod pp. A related form says apa(modp)a^p \equiv a \pmod{p} for any integer aa.

Applications include computing large remainders, checking divisibility patterns, and finding inverses using a1ap2(modp)a^{-1} \equiv a^{p-2} \pmod{p}.

Key Facts

  • If pp is prime and gcd(a,p)=1\gcd(a,p)=1, then Fermat's Little Theorem states ap11(modp)a^{p-1} \equiv 1 \pmod{p}.
  • For any integer aa and prime pp, the equivalent form apa(modp)a^p \equiv a \pmod{p} is always true.
  • When pp is prime and gcd(a,p)=1\gcd(a,p)=1, exponents can be reduced using anar(modp)a^n \equiv a^{r} \pmod{p} where rn(modp1)r \equiv n \pmod{p-1}.
  • If pp is prime and pap \nmid a, the modular inverse of aa modulo pp is a1ap2(modp)a^{-1} \equiv a^{p-2} \pmod{p}.
  • The condition gcd(a,p)=1\gcd(a,p)=1 is required for the form ap11(modp)a^{p-1} \equiv 1 \pmod{p}.
  • If ab(modm)a \equiv b \pmod{m}, then anbn(modm)a^n \equiv b^n \pmod{m} for any positive integer nn.
  • To compute a large power like an(modp)a^n \pmod{p}, first reduce aa modulo pp, then reduce nn modulo p1p-1 when pp is prime and pap \nmid a.
  • Fermat's Little Theorem does not prove that pp is prime just because ap11(modp)a^{p-1} \equiv 1 \pmod{p} holds for one value of aa.

Vocabulary

Prime modulus
A modulus pp that is a prime number, which is required for the standard form of Fermat's Little Theorem.
Congruence
A statement ab(modm)a \equiv b \pmod{m} meaning that aa and bb have the same remainder when divided by mm.
Relatively prime
Two integers aa and bb are relatively prime when gcd(a,b)=1\gcd(a,b)=1.
Modular inverse
The modular inverse of aa modulo mm is a number xx such that ax1(modm)ax \equiv 1 \pmod{m}.
Exponent reduction
Exponent reduction is the process of replacing a large exponent with a smaller congruent exponent, often using nr(modp1)n \equiv r \pmod{p-1}.
Remainder class
A remainder class is the set of all integers that are congruent to the same value modulo mm.

Common Mistakes to Avoid

  • Using ap11(modp)a^{p-1} \equiv 1 \pmod{p} when pap \mid a is wrong because the theorem requires gcd(a,p)=1\gcd(a,p)=1 for that form.
  • Applying Fermat's Little Theorem with a composite modulus is wrong because ap11(modp)a^{p-1} \equiv 1 \pmod{p} is guaranteed only when pp is prime.
  • Reducing the exponent modulo pp instead of modulo p1p-1 is wrong because the power cycle from Fermat's Little Theorem has length dividing p1p-1.
  • Changing a0a^0 to 00 is wrong because a0=1a^0=1 for a0a \neq 0, so an exponent reduction that gives r=0r=0 usually means an1(modp)a^n \equiv 1 \pmod{p}.
  • Assuming one successful Fermat test proves primality is wrong because some composite numbers can satisfy an11(modn)a^{n-1} \equiv 1 \pmod{n} for certain bases aa.

Practice Questions

  1. 1 Find the remainder when 71007^{100} is divided by 1313.
  2. 2 Find the modular inverse of 88 modulo 1717 using Fermat's Little Theorem.
  3. 3 Compute 32025(mod11)3^{2025} \pmod{11}.
  4. 4 Explain why Fermat's Little Theorem can be used to reduce the exponent in 51234(mod19)5^{1234} \pmod{19}, but not directly in 61234(mod21)6^{1234} \pmod{21}.