Pocklington's algorithm is a technique for solving acongruence of the form

wherex anda are integers anda is aquadratic residue.
The algorithm is one of the first efficient methods to solve such a congruence. It was described byH.C. Pocklington in 1917.[1]
(Note: all
are taken to mean
, unless indicated otherwise.)
Inputs:
Outputs:
Pocklington separates 3 different cases forp:
The first case, if
, with
, the solution is
.
The second case, if
, with
and
, the solution is
.
, 2 is a (quadratic) non-residue so
. This means that
so
is a solution of
. Hence
or, ify is odd,
.
The third case, if
, put
, so the equation to solve becomes
. Now find by trial and error
and
so that
is a quadratic non-residue. Furthermore, let
.
The following equalities now hold:
.
Supposing thatp is of the form
(which is true ifp is of the form
),D is a quadratic residue and
. Now the equations

give a solution
.
Let
. Then
. This means that either
or
is divisible byp. If it is
, put
and proceed similarly with
. Not every
is divisible byp, for
is not. The case
withm odd is impossible, because
holds and this would mean that
is congruent to a quadratic non-residue, which is a contradiction. So this loop stops when
for a particularl. This gives
, and because
is a quadratic residue,l must be even. Put
. Then
. So the solution of
is got by solving the linear congruence
.
The following are 4 examples, corresponding to the 3 different cases in which Pocklington divided forms ofp. All
are taken with themodulus in the example.

This is the first case, according to the algorithm,
, but then
not 43, so we should not apply the algorithm at all. The reason why the algorithm is not applicable is that a=43 is a quadratic non residue for p=47.
Solve the congruence

The modulus is 23. This is
, so
. The solution should be
, which is indeed true:
.
Solve the congruence

The modulus is 13. This is
, so
. Now verifying
. So the solution is
. This is indeed true:
.
Solve the congruence
. For this, write
. First find a
and
such that
is a quadratic nonresidue. Take for example
. Now find
,
by computing


And similarly
such that
Since
, the equation
which leads to solving the equation
. This has solution
. Indeed,
.
- Leonard Eugene Dickson, "History Of The Theory Of Numbers" vol 1 p 222, Chelsea Publishing 1952
- ^H.C. Pocklington, Proceedings of the Cambridge Philosophical Society, Volume 19, pages 57–58