Fermat's Little Theorem

April 12, 2026

Problem

Find 2^100 mod 13 using Fermat's little theorem. Show the cyclic pattern of powers.

Explanation

Fermat's Little Theorem

If pp is a prime and aa is not divisible by pp, then:

ap11(modp)a^{p-1} \equiv 1 \pmod{p}

This means ap1a^{p-1} always has remainder 1 when divided by pp. This is incredibly useful for computing large powers mod a prime.

Step-by-step: Find 2100mod132^{100} \mod 13

Step 1 — Check conditions. p=13p = 13 is prime, and gcd(2,13)=1\gcd(2, 13) = 1 (2 is not divisible by 13). ✓

Step 2 — Apply Fermat's Little Theorem. 2121(mod13)2^{12} \equiv 1 \pmod{13} (since p1=12p - 1 = 12).

Step 3 — Express the exponent in terms of 12. 100=12×8+4100 = 12 \times 8 + 4, so:

2100=212×8+4=(212)8×242^{100} = 2^{12 \times 8 + 4} = (2^{12})^8 \times 2^4

Step 4 — Simplify using the theorem.

(212)8×2418×241×1616(mod13)(2^{12})^8 \times 2^4 \equiv 1^8 \times 2^4 \equiv 1 \times 16 \equiv 16 \pmod{13}

Step 5 — Reduce 16mod1316 \mod 13.

16=13+3,so 163(mod13)16 = 13 + 3, \quad \text{so } 16 \equiv 3 \pmod{13}

21003(mod13)\boxed{2^{100} \equiv 3 \pmod{13}}

Verification: Computing 212=40962^{12} = 4096. 4096/13=3154096 / 13 = 315 remainder 11. ✓ So 2121(mod13)2^{12} \equiv 1 \pmod{13}.

The cyclic pattern of powers

212,  224,  238,  243,  256,  2612,  2711,  289,  295,  21010,  2117,  2121(mod13)2^1 \equiv 2, \; 2^2 \equiv 4, \; 2^3 \equiv 8, \; 2^4 \equiv 3, \; 2^5 \equiv 6, \; 2^6 \equiv 12, \; 2^7 \equiv 11, \; 2^8 \equiv 9, \; 2^9 \equiv 5, \; 2^{10} \equiv 10, \; 2^{11} \equiv 7, \; 2^{12} \equiv 1 \pmod{13}

The pattern repeats every 12 steps! This is what Fermat's theorem guarantees.

Why this matters

Without the theorem, computing 2100mod132^{100} \mod 13 would require calculating a 31-digit number. With the theorem, we reduce it to 24=1632^4 = 16 \equiv 3. This shortcut is essential in cryptography — RSA encryption relies on modular exponentiation with very large primes.

Try it in the visualization

Enter base aa and prime pp. The powers a1,a2,,ap1a^1, a^2, \ldots, a^{p-1} are computed mod pp, showing the cyclic pattern. The cycle always returns to 1 at ap1a^{p-1}, confirming Fermat's theorem.

Interactive Visualization

Parameters

2.00
13.00
100.00
Your turn

Got your own math or physics problem?

Turn any problem into an interactive visualization like this one — powered by AI, generated in seconds. Free to try, no credit card required.

Sign Up Free to Try It30 free visualizations every day
Fermat's Little Theorem | MathSpin