MathorynMathematical Formula Database

Number Theory

Fermat's Little Theorem

If pp is prime and aa is not divisible by pp, then ap−1a^{p-1} leaves remainder 1 when divided by pp. It is used in primality tests and modular arithmetic.

ap−1≡1(modp),p∤aa^{p-1}\equiv1\pmod p,\quad p\nmid a
LaTeXa^{p-1}\equiv1\pmod p,\quad p\nmid a

Variables

pp
prime number
aa
integer not divisible by p

Example

Check for a=3, p=7a=3,\ p=7.

  1. 36=729=7⋅104+13^6=729=7\cdot104+1.

Answer: 36≡1(mod7)3^6\equiv1\pmod7.

Related formulas