Fermat's 4n+1 Theorem

Fermat's 4n+1 theorem, sometimes called Fermat's two-square theorem or simply "Fermat's theorem," states that a prime number p can be represented in an essentially unique manner (up to the order of addends) in the form x^2+y^2 for integer x and y iff p=1 (mod 4) or p=2 (which is a degenerate case with x=y=1). The theorem was stated by Fermat, but the first published proof was by Euler.

The first few primes p 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 (x,y) such that x^2+y^2 equal these primes are (1, 1), (1, 2), (2, 3), (1, 4), (2, 5), (1, 6), ... (OEIS A002331 and A002330).

The theorem can be restated by letting


then all relatively prime solutions (x,y) to the problem of representing Q(x,y)=m for m any integer are achieved by means of successive applications of the genus theorem and composition theorem.

See also

Choquet Theory, Diophantine Equation--2nd Powers, Eisenstein Integer, Euler's 6n+1 Theorem, Fermat's Little Theorem, Sierpiński's Prime Sequence Theorem, Square Number

Explore with Wolfram|Alpha


Conway, J. H. and Guy, R. K. The Book of Numbers. New York: Springer-Verlag, pp. 146-147 and 220-223, 1996.Hardy, G. H. and Wright, E. M. An Introduction to the Theory of Numbers, 5th ed. Oxford, England: Clarendon Press, pp. 13 and 219, 1979.Séroul, R. "Prime Number and Sum of Two Squares." §2.11 in Programming for Mathematicians. Berlin: Springer-Verlag, pp. 18-19, 2000.Shanks, D. Solved and Unsolved Problems in Number Theory, 4th ed. New York: Chelsea, pp. 142-143, 1993.Sloane, N. J. A. Sequences A002313/M1430, A002330/M000462, and A002331/M0096 in "The On-Line Encyclopedia of Integer Sequences."

Referenced on Wolfram|Alpha

Fermat's 4n+1 Theorem

Cite this as:

Weisstein, Eric W. "Fermat's 4n+1 Theorem." From MathWorld--A Wolfram Web Resource.

Subject classifications