We evaluate a^{p−1} mod p exactly (and also a^p mod p) using fast modular exponentiation; we explain why the theorem holds, and verify it with multiple harness checks.
When p is prime and gcd(a,p)=1, FLT gives a^{p−1} ≡ 1 (mod p); the corollary a^p ≡ a (mod p) holds for all integers a. For composite p, the congruence may fail.
Each block checks a^{p−1} ≡ 1 (mod p) with gcd(a,p)=1 and notes failures for composite p.