Disclaimer: I'm not a mathematician, nor a student of math. So my knowledge isn't really good and I'm not accustomed at proving theorems.

I need a short and simple proof of this generalization of Fermat's littel theorem:

Theorem: Let and such that and are coprimes.

Then is prime if and only if (eq).

I found a partial proof in one of my books, but there is some part left "as an exercise" which I don't understand how to prove.

The partial proof looks like this:

The coefficient in of the term, for is , and if is prime

then . Thus, for Fermat's little theorem, the (eq) holds(*).

Let us suppose is a composite number and let be one of the prime factors of . Let be the maximum integer such that ,

then (**) and it is relatively prime with .

Thus the coefficient of is non-zero modulo , therefore is not the null-polynomial in ,

or, in other words, (eq) does not hold.

(*) Not complete, but It's trivial to prove. Obviously because the at the numerator is not simplified. Applying the fermat's little theorem to the remaining terms(=first and last) yields the result.

(**) This is the statement left as an exercise, and which I want to prove.

I know that the proof of that little statement must be simple, but I can't find a way of proving it. I'd like to find some very small and simple proof using combinatorics.

Anyone can help me in this task?

By the way: before posting this thread I've searched in this forum, on google, on mathoverflow, but I couldn't find a proof.

I found some references of books containing the proof, but, by what I understood, they prove a more general theorem for

finite fields, so probably the proof requires a deeper knowledge of field theory, and also I haven't got these books at hand.

If anyone knows also the finite-field version, it's welcome to post it.