Prove Fermat's Theorem: if p is prime and (x,p)=1 then xp−1≡1(modp).
Let n and x be positive integers with (x,n)=1. Show that if n=mp where p is prime and (m,p)=1, then
xn−1≡1(modp) if and only if xm−1≡1(modp)
Now assume that n is a product of distinct primes. Show that xn−1≡1(modn) if and only if, for every prime divisor p of n,
x(n/p)−1≡1(modp).
Deduce that if every prime divisor p of n satisfies (p−1)∣(n−1), then for every x with (x,n)=1, the congruence
xn−1≡1(modn)
holds.