Peter wrote:
(Wolstenholme's Theorem) Prove that if

is expressed as a fraction, where

is a prime, then

divides the numerator.
This is an updated version of
an older MathLinks post of mine, and I am submitting it here since I will refer to it in a number of other proofs.
I will generalize the problem, but first I explain some preliminaries about primes.
1. p-adic evaluation
Let

be an arbitrary prime. We denote by

the field of residues of integers modulo

.
For any rational number

, we will now define a so-called
-adic evaluation of 
. This evaluation will be denoted by

, and it is defined as follows: If

, then

is the greatest integer

such that

can be written as a fraction of two integers with the denominator not being divisible by

. Besides, we set

, where

is just a symbol satisfying

and

for any integer

(what we will mainly need is that

for any nonzero

).
We can easily see how to compute

for rationals

:
If

is a nonzero integer, then

is the greatest integer

such that

divides

(particularly,

if

doesn't divide

); if

is a fraction of two nonzero integers, say

with integers

and

, then

.
Note that there is a simple way to interpret the sign of the

-adic evaluation

of a rational number

: If we write

as a reduced fraction (i. e. a fraction with numerator and denominator coprime; if

is an integer, then just write it in the form

), and it turns out that the numerator is divisible by

, then

; if neither the numerator nor the denominator is divisible by

, then

; if the denominator is divisible by

, then

.
It is rather easy to prove that for any two rational numbers

and

, we have

and

.
2. Working with fractions modulo p
We will also need some familiarity with fractions in

. The main idea is to extend the notion of congruence modulo

from integers to rational numbers with nonnegative

-adic evaluation: If

and

are two rational numbers such that

and

, then we say that

if and only if

. Thus we have defined an equivalence relation (that it is an equivalence relation is easy to prove - do it for yourself) on the set of all rational numbers with nonnegative

-adic evaluation. Now one could expect that, in this way, we would obtain a kind of new group of remainders, say

- but in fact, we get nothing but our old familiar

, since for every rational number

, there is one and only one integer

satisfying

such that

(this is again easy to prove). Hence, you can work with rational numbers whose

-adic evaluation is nonnegative in the same way as you work with remainders modulo

. This also means that modulo

, you can uniquely divide by any integer not divisible by

. [A nice application of this is
problem 4 of the IMO 2005 - see Fedor Petrov's proof in post #2.]
3. Generalization of Wolstenholme's Theorem
Now, the problem A 23 asks us to show that if

is a prime number such that

, then

. This is a particular case (namely, the

case) of the following result:
Theorem 1. If
is a prime number and
is an odd integer such that
and
, then
.
Proof of Theorem 1. We will first work in

and only later come over into

. Note that

(since

and

). We start with the Gauss trick:

.
Now denote

for every

. Obviously,

is an integer for every

. We can expand

according to the binomial formula:

(since u is odd, so that

and

)

.
Thus,

for every

, and therefore

.
But since

isn't divisible by

(since

), we have

, so that

.
On the other hand,

.
Thus,

.
Hence, instead of showing

, it will be enough to prove

. This is equivalent to

, i. e. to

. Now we start working in

. In fact, for every

, we can consider the fraction

in

, since it has a nonnegative

-adic evaluation (because its denominator,

, is not divisible by

, since

and since

is a prime). Modulo

, the numerator

of this fraction can be simplified to

(since

, and thus all terms containing

can be omitted). Also, the denominator can be simplified: Since

, we have

. Hence,

. Therefore,
(1) 
.
But by Fermat's small theorem,

for every integer

such that

. Thus,

, and the relation
(1) becomes

.
Now,

(since

) and

. Also,

is an odd prime (since

is a prime and

). Now, according to
http://www.problem-solving.be/pen/viewtopic.php?t=676 part
a) (and also
http://www.artofproblemsolving.com/Forum/viewtopic.php?t=40171 ), we have:
Theorem 2. If
is an odd prime and
is an integer such that
, then
.
Applying this Theorem 2 to our prime

and

(we know that

is an odd prime and

satisfies

), we get

, so that

, and thus

.
This completes the proof of Theorem 1.
4. A divisibility by
We can use almost the same tactics to prove a similar result:
Theorem 3. If
is a prime number such that
, then
.
Proof of Theorem 3. It is known that for every integer

such that

, we have

(since

is prime); in other words,

.
Besides,

(since

).
Set

. Also, denote

for every

. Obviously,

is an integer for every

. Then, every

satisfies

(since

)

.
We will first work in

and only later come over into

. Just as in the proof of Theorem 1, we can show that
(2) 
.
Since

, we have
and

(since

)

.
Thus,
(2) becomes

.
In other words,

.
Hence, instead of showing

, it will be enough to prove

. This is equivalent to

, i. e. to

. Now we start working in

. In fact, for every

, we can consider the fraction

in

, since it has a nonnegative

-adic evaluation (because its denominator,

, is not divisible by

, since

and since

is a prime). Modulo

, the numerator

of this fraction can be simplified to

(since

, and thus the term

can be omitted). Also, the denominator can be simplified: Since

, we have

. Hence,

. Therefore,
(3) 
.
But by Fermat's small theorem,

for every integer

. Thus,

, so that

. Hence, the relation
(3) becomes

.
Now,

(since

yields

, and

) and

. Also,

is an odd prime (since

is a prime and

). Applying Theorem 2 to our prime

and

(we know that

is an odd prime and

satisfies

), we get

, so that

, and thus

.
This completes the proof of Theorem 3.
[EDIT: Made the proof of Theorem 1 slightly more formal, and added section 4. See
the other thread for the old version of this post.]
Darij