
means there is an integer

such that

, or

.
Raising both sides to an arbitrary integer power, we have

Notice that each term in the expansion on the right is a multiple of 7 when

, which means modulo 7, the right side reduces to 1. Therefore if

, then

as well.
More generally, the remainder of a number

upon dividing by 7 will be determined by the constant term (independent of

) in the binomial expansion, because any term with a contributing factor of

necessarily is a multiple of 7.
You then have



Now,

Recall that for

and

, we have

, which means we can determine the remainder above by multiplying the remainders given by

and

.
In particular, if

, then

Now, we get by this property in conjunction with Fermat's little theorem that
















So we obtain


