Theorem. Let p be any prime. A finite group G has a subgroup of order p if and only if p divides the order of G. In that case, the number of p-element subgroups H of G is congruent to 1 mod p.

*Proof*:
Let |G|=N. Certainly the condition that p|N is necessary
since [G:H] must be an integer. Assume now that N is a multiple of p.
We shall show that the number of elements of order p in G
is congruent to p-1 mod p. In particular it is nonzero.
Since each such element is contained in a unique p-element group H,
which contains p-1 elements of order p, it will also follow that
the number of such groups H is congruent to 1 mod p
(and in particular is not zero).

Consider the solutions of x_{1}x_{2}...x_{p}=1
in G. There are exactly N^{p-1} of them, one for each choice
of x_{1},x_{2},...,x_{p-1}.
Note that N^{p-1} is a multiple of p.
But if (x_{1}x_{2}...x_{p}) is a solution,
so are all of its cyclic permutations. Since p is prime,
the cyclic permutations are either all distinct or all equal,
the latter being the case if and only if the x_{i}
are all equal. Hence the number of x in G such that x^{p}=1
is a multiple of p. But x solves this equation if and only if it is
either the identity or an order-p element. Therefore the number of
order-p elements is congruent to -1 mod p, as claimed.

(Such arguments can be extended to give one of the standard proofs of the Sylow theorems. For our present purpose, the exact residue mod p of the number of x's or H's doesn't really matter, only the fact that these counts are not multiples of p.)

Theorem.
A nontrivial p-group has nontrivial center.

(A *p-group* is a group whose order is some power of a prime p.
A nontrivial p-group is thus one whose order is p^{n}
for some n>0.)

*Proof*: Let G be a nontrivial p-group,
and P the set of order-p elements of G.
We have seen that P is nonempty, and indeed that |P|
is congruent to -1 mod p.
Now consider the action of G on P by conjugation.
The stabilizer under this action of any x in P is the
centralizer C(x) of x, which is the subgroup of G
consisting of all elements that commute with x.
The orbit of x then has size [G:C(x)].
But G is a p-group, so [G:C(x)] is a power of p.
Hence [G:C(x)] is either 1 or a multiple of p.
Since |P| is not a multiple of p, it follows
that at least one of the orbits is a singleton.
Then C(x)=G, which is to say that x commutes with every element of G.
We have thus found a nontrivial element x of the center of G,
**QED**.

Tony Varilly notes a simpler *proof*:
The center of any group is the union of the 1-element conjugacy
classes in the group. For a p-group, the size of every conjugacy class
is a power of p. Thus a nontrivial p-group always has at least p-1
non-identity conjugacy classes (since {1} is always a singleton
conjugacy class). Hence the center is nontrivial, as claimed.