FP2 5.4 - Fermat's little theorem

FP2 5.4 - Fermat's little theorem

Use Fermat's little theorem to reduce large powers modulo a prime (FP2 5.4). You will check its conditions, reduce exponents, use convenient signed bases and finish with the requested residue.

Check the prime modulus and the base

What is the remainder when 710007^{1000} is divided by 1313? Expanding the power would bury the answer in an enormous integer. Fermat's little theorem lets you replace long stretches of multiplication by a return to residue 11.

You already know

With a fixed modulus, congruences are preserved by multiplication and positive integer powers. A negative representative is allowed during working. The least nonnegative residue lies in 0,…,n−10,\ldots,n-1; the least positive representative lies in 1,…,n1,\ldots,n.

Here is the concrete pattern behind the shortcut: modulo 1313, repeatedly multiplying by 77 eventually returns to 11, with 712≡1(mod13)7^{12}\equiv1\pmod{13}. The theorem gives such a guaranteed return for every base not divisible by a prime modulus.

Fermat's little theorem

If pp is prime and aa is an integer not divisible by pp, then

ap−1≡1(modp)a^{p-1}\equiv1\pmod p

An equivalent form, valid for every integer aa when pp is prime, is

ap≡a(modp)a^p\equiv a\pmod p

The first form requires gcd⁡(a,p)=1\gcd(a,p)=1. If p∣ap\mid a, every positive power of aa is congruent to 0(modp)0\pmod p.

Not in the formula booklet: learn it.

For a prime pp, either p∣ap\mid a or gcd⁡(a,p)=1\gcd(a,p)=1. Multiplying the first form by aa gives the second in the coprime case; the divisible case gives zero on both sides. Conversely, safe cancellation of aa in the second form gives the first when gcd⁡(a,p)=1\gcd(a,p)=1. A proof of the theorem itself is not required.

Worked example 1: both forms apply

Question. Use Fermat's little theorem to determine the least nonnegative residues of 4124^{12} and 4134^{13} modulo 1313.

Plan. Check that the modulus is prime and the base is not divisible by it, then identify the exponents p−1p-1 and pp.

13 is prime,13∤4check both conditions412≡1(mod13)the p−1 form413≡4(mod13)the p form\begin{aligned} 13&\text{ is prime},\qquad13\nmid4 &&\text{check both conditions}\\ 4^{12}&\equiv1\pmod{13} &&\text{the }p-1\text{ form}\\ 4^{13}&\equiv4\pmod{13} &&\text{the }p\text{ form} \end{aligned}

Why this step? The exponent yielding residue 11 is one less than the prime modulus, not the prime modulus itself.

Answer. The residues are 11 and 44, respectively.

Check. 43=64≡−1(mod13)4^3=64\equiv-1\pmod{13}, so 412=(43)4≡(−1)4=1(mod13)4^{12}=(4^3)^4\equiv(-1)^4=1\pmod{13}; one more factor of 44 gives residue 44.

Change only the base from 44 to 2626, keeping the two exponents and the modulus fixed. One theorem condition now fails.

Worked example 2: the base is divisible by the prime

Question. Determine the least nonnegative residues of 261226^{12} and 261326^{13} modulo 1313. Explain which form of Fermat's little theorem applies.

Plan. Check divisibility before using the p−1p-1 form; use the power law for a zero residue.

26=2(13)≡0(mod13)the base is divisible by 132612≡012=0(mod13)power law2613≡26≡0(mod13)the p form still applies\begin{aligned} 26&=2(13)\equiv0\pmod{13} &&\text{the base is divisible by }13\\ 26^{12}&\equiv0^{12}=0\pmod{13} &&\text{power law}\\ 26^{13}&\equiv26\equiv0\pmod{13} &&\text{the }p\text{ form still applies} \end{aligned}

Why this step? The statement 2612≡1(mod13)26^{12}\equiv1\pmod{13} would use the first form outside its domain.

Answer. Both residues are 00. The pp form applies, but the p−1p-1 form does not.

Check. Every positive power of 26=2(13)26=2(13) contains a factor of 1313.

The modulus and the base play different roles: primeness is a condition on the modulus, while coprimality is the additional condition for the p−1p-1 form.

Watch out

Do not write ap≡1(modp)a^p\equiv1\pmod p as Fermat's theorem. With a=4, p=13a=4,\ p=13, the correct line is 413≡4(mod13)4^{13}\equiv4\pmod{13}; the exponent that gives 11 is 1212. Also check p∤ap\nmid a before using that p−1p-1 form.

State the applicable theorem before reducing powers; this makes the role of its conditions visible.

Remove complete blocks of the exponent

Once ap−1≡1(modp)a^{p-1}\equiv1\pmod p, every complete block of p−1p-1 factors contributes residue 11. Divide the exponent by p−1p-1, then retain its remainder.

Exponent reduction using Fermat

For prime pp, integer aa with p∤ap\nmid a, and nonnegative integer NN, write

N=q(p−1)+r,0≤r<p−1N=q(p-1)+r,\qquad0\leq r<p-1

Then

aN=(ap−1)qar≡1qar≡ar(modp)a^N=(a^{p-1})^q a^r\equiv1^q a^r\equiv a^r\pmod p

When r=0r=0, the retained power is a0=1a^0=1.

Not in the formula booklet: learn it.

This reduces the exponent modulo p−1p-1; the value of the power is still reduced modulo pp. Those are different jobs.

Worked example 3: a thousand factors become four

Question. Use Fermat's little theorem to determine the least positive residue of 710007^{1000} modulo 1313. Show detailed reasoning.

Plan. State the theorem for this base and prime, divide 10001000 by 1212, then evaluate only the retained power.

712≡1(mod13)13 prime, 13∤71000=83(12)+4divide the exponent by p−171000=(712)8374≡74(mod13)remove complete blocks72=49≡10(mod13)reduce a smaller power74≡102=100≡9(mod13)square and reduce\begin{aligned} 7^{12}&\equiv1\pmod{13} &&13\text{ prime},\ 13\nmid7\\ 1000&=83(12)+4 &&\text{divide the exponent by }p-1\\ 7^{1000}&=(7^{12})^{83}7^4\equiv7^4\pmod{13} &&\text{remove complete blocks}\\ 7^2&=49\equiv10\pmod{13} &&\text{reduce a smaller power}\\ 7^4&\equiv10^2=100\equiv9\pmod{13} &&\text{square and reduce} \end{aligned}

Why this step? Reducing the exponent before calculating the remaining power is precisely the use of Fermat's theorem requested in the question.

Answer. The least positive residue is 99.

Check. 74=2401=184(13)+97^4=2401=184(13)+9, and 1≤9<131\leq9<13.

Increase only the exponent by 11. The same complete blocks remain, but the retained power gains one factor of 77.

Worked example 4: one extra factor

Question. Use Fermat's little theorem to determine the least positive residue of 710017^{1001} modulo 1313.

Plan. Use the same theorem and divide the new exponent by 1212; reuse the known residue of 747^4.

712≡1(mod13)13 prime, 13∤71001=83(12)+5one larger remainder71001≡75(mod13)remove complete blocks75=74(7)≡9(7)=63≡11(mod13)multiply by one extra 7\begin{aligned} 7^{12}&\equiv1\pmod{13} &&13\text{ prime},\ 13\nmid7\\ 1001&=83(12)+5 &&\text{one larger remainder}\\ 7^{1001}&\equiv7^5\pmod{13} &&\text{remove complete blocks}\\ 7^5&=7^4(7)\equiv9(7)=63\equiv11\pmod{13} &&\text{multiply by one extra }7 \end{aligned}

Why this step? A remainder of 55 means retain 757^5, rather than replacing the whole power by the integer 55.

Answer. The least positive residue is 1111.

Check. 9(7)=63=4(13)+119(7)=63=4(13)+11, so it is the next residue after 99 in the repeated-multiplication cycle.

Continue this lesson.

You’re previewing NovaLearn without an account. Create a free account to read the rest.

Create free account