AlgoScope

Fermat's Little Theorem

MathematicsintermediateNumber Theory

For prime p and a not divisible by p, a^(p-1) = 1 mod p.

Decision · step 7 of 8Multiples, Powers, Pascal: 3 to the 6 mod 7
3✓02✓16✓24✓35✓41✓5i

3^6 = 5 x 3 mod 7 = 15 mod 7 = 1. Exponent 6 lands on 1, as Fermat promised.

Open in the player →or start at step 7

What you will see

Powers of a mod p cycle back to 1 at exponent p - 1.

How multiples, powers, pascal works →

Cost

SpaceO(1)

How you work with it here

play it through, step one change at a time, run it on your own input.

Screen readers: Numbers announce their value and role; each step announces the arithmetic performed.

Reduced motion: Values crossfade; no travelling digits.

Leads to

Topics that need this one first.

Taught by the same lesson

Multiples, Powers, Pascal covers these too, in the same run.