Prime Test
We know that if n is prime, then:
{a^(n-1)}%n=1 [Fermat primality test]
Can anyone explain its mathematical proof?