(a) Fermat's little theorem states that for any prime , we have
for any integer . Then
so 7 does indeed divide 999,999.
(b) Generalizing, we have
for positive integer . Now, since 1 = 1001 - 1000 and , it follows that is its own inverse modulo 1001, i.e.
This means
which is what we wanted to show.