A new elementary approach to the Girard-Fermat theorem, generalizing the equality of the sum of squares with the prime to its divisibility by that prime. That reveals some interesting properties of the corresponding decomposition’s components.
The issues of the numbers which are sum of two squares has been addressed early. It has been studied the amount of different representations of the same number as a sum of squares, and the conditions that a number has such representations. Some first results, albeit accompanied by uncertainly and inaccuracy, as quoted by Dixon 1 pg. 225, are mentioned by Diofant and Mohammed Ben Alhocain (Arab mathematician in tenth century). The first exact formulations of the existence of such representations are mentioned at 1 pg. 227.
The earliest one is that of Albert Girard (1625) - “a number is a sum of two squares only when: It is a square, it is a prime of the form , it is the product of such numbers, and when it is the double of one of the foregoing”. Fermat (1640) wrote that the condition for a number of the form to be a sum of two squares, the number must not be odd, and , when divided by the greatest square entering it as a factor, must not be divisible by any prime of the form (as quoted by 1). Fermat (quoted by Dickson 1, pg. 228) calls the proposition staying in the core of their formulations: “Every prime number is a sum of two squares” the “fundamental theorem on right triangles”. Dickson himself calls it “Girard theorem”.
Generally, the proposition:
Theorem 1.1. An odd prime can be expressed as
with
and
integers, if and only if
.
is called “Fermat’s theorem on sums of two squares”. The prime numbers for which this is true are called Pythagorean primes.
Its proof has a long history too. Fermat asserts (as Dickson 1 quoted at pg. 228) that it has an irrefutable proof, based on the “method of indefinite descent”. The first known irrefutable proof is that of Euler (1747, 1749), another one is that of Lagrange (1775), simplified by Gauss. Dedekind has provided two ones, which use the ring of Gaussian integers; are also well known two quite different and almost recent ones by Heath Brown and Zagier 2.
We’ll call it “the Girard-Fermat’s two-square theorem”.
The uniqueness of prime’s representation as sum of squares was observed early by Euler, which, for the numbers that appeared in two different ways as sums of squares, offered a factorization method, leading to an factorizing algorithm running in
steps 3.
The following results will be used in our approach to the demonstration of the Girard-Fermat theorem.
Theorem 1.2. 4 If
is a prime number such that
, then
or
.
Theorem 1.3. 5 Let
be a polynomial with integer coefficients and
the canonical factorization of the positive integer
. The number of roots of the equation
equals the product of the roots’ numbers of the following equations
such Let
be a prime of the form
. In this section we find all the pairs of positive integers
,
, such that
and some their interesting properties.
We will use the following proposition:
Theorem 2.1. 6 If
is a prime
, then for every divisor
of
the congruence
has
distinct solutions smaller than
.
If the prime
is
, then
for some
. So, for the divisor
of
theorem 2.1. yields that the congruence
, has
distinct solution. Let as denote them by
. (∗)
Theorem 2.2. 7 Consider the congruence
for some
. If
is a primitive root modulo
and
, then the given congruence is equivalent to the congruence
This congruence is linear regarding
and admits solutions if
is divisible by
. If this is the case, it has
distinct solutions.
The prime number
has primitive roots, let
be one of them. For each
at (∗)
, let us consider the congruence
These congruences satisfy the conditions of Theorem 2.2., for
,
, so they are equivalent to the corresponding
Necessary and sufficient condition for these linear congruences to admit any solution is that
.
is a primitive root modulo
, so
. Also, by
we get
Taking into account that
,
, we have
which means that
being
a primitive root modulo
. This way we have that
.
So, even the indexes
must be multiples of 4. Since
, the congruences
have solutions, then each one of them has 4 distinct ones.
Let us consider the first two positive solutions of each one of the following
equations:
All of them are in the set
. Taking into account that there are
such congruences, each one of them having two distinct solutions in the set
, then the numbers
can be organized in couples
such that for each one of them
,
.
For the positive integers
and
we have:
wherefrom
because
, with
and
such
.
We have proved the following:
Theorem 2.3. For every prime
, the set
can be divided in
couples of numbers, the sum of squares of each of them being divisible by the prime
.
Example 2.4. For the prime
we have the following “decompositions” in sums of two squares:
So, the numbers
are divided in 7 couples, the sum of squares of each one of them is divisible by 29.
In the following, we will can two couples of natural numbers
and
congruent modulo
,
, if
and write
We put also the following “scalar multiplication” in the set of couples
Definition 2.5. Let
be a prime number. We will call as “a square couple of the prime
” every couple of non-negative integers
such that
. A square couple
of
is called a “primitive square couple” if
.
In the following, we will not make any distinction between the couples
and
, considering them the same couple.
Theorem 2.6. For every prime
there are exactly
primitive square couples of
, generated by multiplying any arbitrary primitive square couple by elements of a reduced residue system modulo
.
Proof. Since for every
the congruence
has exactly two solutions in this set, then for every such
exist exactly two primitive square couples of
which have the number
. But the number of elements of the set
is
and every number
appears twice in these primitive square couples, so there are exactly
primitive square couples of the prime 
Let
be any primitive square couple of the prime
and
the respective reduced residue system. Let us now consider the following
primitive square couples:
They are all different from each other. Indeed, if
then
Example 2.7.
is a primitive square couple of the prime
. Using the construction of the proof of theorem 2.6. we get the following list of all primitive square couples of 13:
Corollary 2.8. For every two square couples
and
of the prime
, there is a positive integer
such that:
Theorem 2.9. If
and
are squares couples of the prime
, the for every
,

is also a square couple of the prime
.
Proof. Corollary 2.8. yields a positive integer
, such that
, namely
and
.
Since
we have
. So, the couple
is a square couple of prime
.
Remark 1. We have these special cases:
● For
. If
and
are square couples of prime
, then
is also a square couple of the prime
.
● For
. If
and
are square couples of prime
, then
is also a square couple of the prime
.
Theorem 2.10. Let
be a prime
. Then the sums of the components of the
primitive square couples of
form a reduced residue system modulo
.
Proof. Firstly, we show that if
is a primitive square couple of
, then
. Indeed, if
then
, consequently
, which is impossible because
.
Since there are
primitive square couples, to prove the theorem it suffices to show that for every two primitive square couples the sums of their components are not congruent modulo
. Suppose that
and
are two primitive square couples such that
By Corollary 2.8. exists
such that
and
. So, we have
which, taking into account that
, means that
and
,
are not different.
In this section we will present two new proofs of Girard-Fermat Theorem, relying on the results of the section 2.
Theorem 3.1. (Girard-Fermat) Every prime number of the form
can be expressed as a sum of two squares of two natural numbers in only one way.
Proof. Let
a primitive square couple of the prime
with the least sum of its components, whose existence is provided by Theorem 2.10. We will now prove that
.
First proof. Let as suppose that
. Since
is a primitive square couple, then
for any natural
and by Theorem 1.2. all the divisors of
are
.
By Theorem 1.3. the number
can be expressed as sum of two squares in at least two ways:
Supposing that
and
we have:
By the supposition
, so

and, taking into account that
we obtain that
We denote by
. We have to prove that
. If
then the equality
gives
and
,
whereby the contradiction:
If
, than the couples of numbers
,
and
,
have the same parity, so the halves
,
,
,
, are integers. Similarly, we get that the equalities
and 
yield
and
,
whereby the contradiction:
.
So,
and
is a primitive square couple whose sum of components is:
,
which contradicts our supposition
.
Second proof. Firstly, we see that
. Indeed, if
, then
is also a primitive square couple, because
and
.
But the sum of elements of this couple is
, which is impossible. The positive integer
and
can’t be both odd. Indeed, if we get
, since:
and
the couple
is a primitive squares couple. So, the sum of elements of this couple is
and
, which is impossible. Also, the positive integers
and
cannot be both even, because
. Consequently, a primitive square couple of prime
with the smallest sum of its elements has one component an odd number and the other an even number.
Suppose now that
. Since
, there is any integer
such that
. But, from Theorem 1.2. the divisors of
are all
. By Theorem 1.3., the number
can be expressed as sum of two squares in at least two ways:
We see that the parities of
and
must be different, because those of
and
are different. Suppose that
and
. Then
.
Since
we have
, then
Now, since
and
are square couples of the prime
, by Theorem 1.2. we have that:
is also a square couple of the prime
. We noticed that the parities of
and
are different and the same holds for
and
, so the components of the couple
have the same parity. The following two cases are possible:
Case 1. The numbers
and
are both odd. Since
, there is a square couple
with sum of its elements
. But, since:
then
, wherefrom
which contradicts the assumption.
Case 2. The numbers
and
are both even. The couple
is a square couple and the sum of its elements is
But, since
we have:
which also contradicts the assumption.
| [1] | Dickson, Leonard Eugene (2005) [1920] - History of the theory of numbers. Vol. II: Diophantine analysis, New York: Dover Publications, ISBN 978-0-486-44233-4. | ||
| In article | |||
| [2] | Zagier, D. (1990) A one-sentence proof that every prime p ≡ 1 mod 4 is a sum of two squares, American Mathematical Monthly, 97 (2): 144. | ||
| In article | |||
| [3] | James McKee Turning Euler’s factoring method into a factoring algorithm Bull. Lon don Math. Soc. 28 (1996) 351-355. | ||
| In article | |||
| [4] | Sato N.: Art of Problem Solving (Notes on Number Theory for students at the IMO), https:// artofproblemsolving.com/ articles/files/SatoNT.pdf (accessed at February 17, 2019). | ||
| In article | |||
| [5] | Sierpinski W.: Elementary theory of Numbers, North-Holland, PWN-Polish Scientific Publisher. | ||
| In article | |||
| [6] | Adler A., Coury J.E.: The Theory of Numbers, Jones and Barlett Publisher, Boston, London, Singapore, 1995. | ||
| In article | |||
| [7] | Apostol T.M.: Introduction to Analytic Number Theory, Springer-Verlag 1976. | ||
| In article | |||
Published with license by Science and Education Publishing, Copyright © 2026 Arto Adili, Adrian Naço and Lorena Kelo
This work is licensed under a Creative Commons Attribution 4.0 International License. To view a copy of this license, visit
http://creativecommons.org/licenses/by/4.0/
| [1] | Dickson, Leonard Eugene (2005) [1920] - History of the theory of numbers. Vol. II: Diophantine analysis, New York: Dover Publications, ISBN 978-0-486-44233-4. | ||
| In article | |||
| [2] | Zagier, D. (1990) A one-sentence proof that every prime p ≡ 1 mod 4 is a sum of two squares, American Mathematical Monthly, 97 (2): 144. | ||
| In article | |||
| [3] | James McKee Turning Euler’s factoring method into a factoring algorithm Bull. Lon don Math. Soc. 28 (1996) 351-355. | ||
| In article | |||
| [4] | Sato N.: Art of Problem Solving (Notes on Number Theory for students at the IMO), https:// artofproblemsolving.com/ articles/files/SatoNT.pdf (accessed at February 17, 2019). | ||
| In article | |||
| [5] | Sierpinski W.: Elementary theory of Numbers, North-Holland, PWN-Polish Scientific Publisher. | ||
| In article | |||
| [6] | Adler A., Coury J.E.: The Theory of Numbers, Jones and Barlett Publisher, Boston, London, Singapore, 1995. | ||
| In article | |||
| [7] | Apostol T.M.: Introduction to Analytic Number Theory, Springer-Verlag 1976. | ||
| In article | |||