For the proof of Fermat's Little Theorem, it ends up being that
$(p-1)!\cdot a^{(p-1)} \equiv (p-1)!\pmod{p}$ then since $p ∤ (p-1)!$ when $p$ is prime
$a^{(p-1)} \equiv 1 \pmod{p}$
(as seen here)
I understand why $p ∤ (p-1)!$ when $p$ is prime and why it fails when $p$ is composite, however, there exists (the only?) exception which is $4$. (as $4 ∤ 3!$)
So then why is it that Fermat's Little Theorem doesn't work when $p = 4$ and $(a,4) = 1?$
i.e. why is $7^{(4-1)} \equiv 1 \pmod{4}$ not true, despite it satisfying the conditions of the proof
Thank you
(Apologies if it is just something stupid that I have overlooked)
(p−1)!≡a⋅2a⋯(p−1)a≡ap−1(p−1)!(modp)⟹ap−1≡1(modp)
– TheyWereConnected Jul 26 '22 at 19:29