Fermat's Little Theorem states that if p is prime then a^p - a is a multiple of p. In other words,

a ^ (p-1) = 1 mod p, whenever a is not a multiple of p

The proof for this theorem is interesting. Take any number a that is co-prime with p. Now, a will correspond to some r (mod) p, where r lies between 1 and p-1

Now, take the numbers a, 2a, 3a, 4a, 5a,...(p-1)a...All these numbers will be co-prime with p (as p is prime) and all will leave remainders from 1 to p-1. Let us assume they leave remainders r, r2,r3,r4, …rp-1. Now, none of these remainders will be equal to 0. Importantly, no two of these remainders can be equal.

(This is a critical result, which is established below)

Suppose r3 were equal to r5. Then, 5a -3a would be a multiple of p => 2a is a multiple of p, which is impossible.

This implies r, r2,r3,r4, …rp-1 should correspond to 1,2,3,...p-1 in some order.

Now, when we multiply a, 2a, 3a, 4a,...(p-1)a in modular arithmetic terms, we should get a remainder of 1*2*3*...(p-1)

Or, a p-1 * 1*2*3*...(p-1) = 1*2*3*...(p-1) mod p

Let us say 1*2*3*...(p-1) = X

Or, a p-1 * X = X mod p

Or, X (a p-1 -1) = 0 mod p

Now, X cannot be 0 mod p, so, a ^ (p-1) has to be 1 mod p, which is Fermat's Little Theorem

Now, m and n are co-prime numbers. The possible remainders that m can have when divided by n are numbers from 0 to n-1 that are co-prime to n. A set that has phi(n) elements. We have seen this result here .

Now, let the elements in that set be R1 R2,R3,R4, …Rp set of possible remainders that m can leave when divided by n. This implies that p = phi(n).

Now, let us assume that m leaves a remainder R on division by n, R belongs to the above mentioned set.

Let us take the numbers R1 * m, R2* m, R3* m,R4* m, …Rp* m. Now, none of these would correspond to o mod n. Importantly, no two of these can be equal mod n either.

Because if R4* m andR7* m were equal mod n, then m *( R4- R7) would be a multiple of n, which is impossible.