費馬小定理

$a$ 是一個整數，$p$ 是一個質數

$a^p \equiv a \pmod{p}$

$gcd(a, p) = 1$

$a^{p-1} \equiv 1 \pmod{p}$

the converse of fermat's little theorem is not generally true, as it fails for Carmichael numbers

歐拉定理 ( Euler's Theorem )

$a^{\varphi(n)} \equiv 1 \pmod{n}$