1. Introduction
Fermat’s two square theorem states that an odd prime
can be represented as a sum of two squares if and only if
(mod 4) [1]. However, this classical theorem only reveals the property of representability as a sum of two squares for primes congruent to 1 modulo 4, while little attention has been paid to the complete picture: using the number of such representations to detect primality for a general positive integer congruent to 1 modulo 4.
The recent article [2] presents a criterion for testing the primality of square-free positive integers congruent to 1 modulo 4, based on the uniqueness of representations as a sum of two squares. It goes beyond Fermat’s theorem and establishes a two-way connection between uniqueness of representation as a sum of two squares and primality. Modern primality tests include the deterministic, polynomial-time AKS algorithm [3] and the probabilistic Miller-Rabin test [4] [5], whose error probability can be reduced through repeated rounds. Unlike these computational algorithms, the theorem in [2] connects primality to the uniqueness of representation as a sum of two squares.
Unfortunately, the proof of the main theorem relies on the implicit assumption that the constructed representations are pairwise distinct, but a justification was not provided.
In this paper, we further clarify the counting step in the proof of the main theorem in [2], showing that the representations generated in Step 2 of Section 3 are pairwise distinct up to order and signs.
2. Two Supplementary Proofs of the Theorem
We first recall the main theorem of [2].
Two integer pairs are regarded as equivalent if one can be obtained from the other by changing order and signs independently. The representation of an integer
as a sum of two squares is considered unique if all integer solutions of
form exactly one equivalence class under this relation.
Theorem Let
be a square-free positive integer larger than 1 and
(mod 4). If
has a unique representation as a sum of two squares for a pair of integers
and
, then
is prime.
The authors of [2] prove the theorem by offering the following method to construct
candidate representations as a sum of two squares for
. Since such a representation exists, every prime factor congruent to 3 modulo 4 must occur with an even exponent. Combined with the fact that
is square-free,
’s are all distinct primes congruent to 1 modulo 4.
The first factor
has a representation
by Fermat’s two square theorem.
Assume that
has a representation
, where
, and a representation
of
has already been obtained. The Brahmagupta-Fibonacci Identity gives two representations for
:
After incorporating all
factors, this process generates
candidate representations.
In [2], these
candidate representations are regarded as pairwise distinct up to order and signs in the proof of the main theorem, but this does not immediately follow. We now provide two ways to justify this counting step.
The first is to justify that the candidate representations are pairwise distinct up to order and signs by the following lemma.
Lemma The
candidate representations as a sum of two squares are pairwise distinct, where we consider two representations the same if they differ only in the order of the summands or in signs.
Proof:
We prove the lemma by induction. The first prime factor
has a unique representation class by Fermat’s Theorem. Suppose that
has
distinct representation classes
. Using the construction in [2], we obtain
representations of
. We show that each of these
representations
is generated uniquely from a pair
along with one of the two Brahmagupta-Fibonacci identities.
Any representation
of
that generates representation
of
must satisfy
or
By solving four linear systems arising from the sign choices in the absolute values, we obtain the following two possible solutions of
(the remaining two candidates have non-positive components and are discarded):
If both of the solutions for A and B are feasible, then
divides both
and
. Hence
divides
, which forces
to divide
, contradicting that the prime factors
are distinct. Therefore,
is generated in exactly one way. Hence each induction step doubles the number of distinct representation classes. This proves the lemma. ■
The lemma justifies the distinctness, up to order and signs, of the representations generated by the iterative construction in [2]. Therefore, at least
representations are found by this construction. From this, unique representation as a sum of two squares leads to primality.
Another direct way is to prove the main theorem of [2] without the construction. In fact, we can get the number of representations from Jacobi’s two square theorem [6] [7]. Jacobi’s theorem states that the number of integer solutions
of
is
, where
and
denote the numbers of positive divisors of
congruent to 1 and 3 (mod 4) respectively. As demonstrated in Step 1 of [2], the integer
in the main theorem has only distinct prime factors congruent to 1 modulo 4. Therefore, the number of such solutions is
On the other hand, if the representation of
as a sum of two squares is unique, then it has exactly eight integer solutions
, since neither coordinate can be zero when
is square-free, and their absolute values cannot be equal when
is odd. Thus,
leads to
. This proves the theorem.
3. Conclusion
We justify that the representations constructed in the proof of [2] are pairwise distinct, and we also provide an alternative proof based on Jacobi’s two square theorem. The main contribution of [2], together with the supplementary proofs presented in this paper, is to extend the scope of Fermat’s two square theorem by developing the representability of integers as sums of two squares from a property of primes into a criterion for primality testing.
Acknowledgements
The author thanks Way Kuo for insightful discussions. This research is supported by City University of Hong Kong project No. 9610556.