Fermat's
theorem, sometimes called Fermat's two-square theorem or simply "Fermat's
theorem," states that a prime number can be represented in an essentially
unique manner (up to signs and the order of addends) in
the form
for integer and iff or (which is a degenerate case with ). The theorem was stated by Fermat, but the first published
proof was by Euler.
The first few primes which are 1 or 2 (mod 4) are 2, 5, 13, 17, 29, 37, 41, 53,
61, ... (OEIS A002313) (with the only prime
congruent to 2 mod 4 being 2). The numbers such that equal these primes are
(1, 1), (1, 2), (2, 3), (1, 4), (2, 5), (1, 6), ... (OEIS A002331
and A002330).