# Sum of two squares representation

I found the following condition: A positive integer $n$ is re-presentable as the sum of two squares, $n=x^2+y^2$ if and only if every prime divisor $p≡3$ mod $4$ of $n$ occurs with even exponent.

And $p$ is re-presentable as sum of $2$ squares only when $p≡1$ mod $4$, where $p$ is a prime.

$36=2^23^2$, here power of $3$ is $2$. Then how come $36$ cannot be represented as sum of $2$ squares, except the trivial case $6^2+0^2$?

What is the sufficient condition for $2$-square representation (not the trivial one) for any $n$?

• If $n$ has a prime divisor of the form $4k+1$, and all primes of the form $4k+3$ occur to an even power, then $n$ is non-trivially representable. The only other non-trivially representable natural numbers are of the form $2^k w$, where $w$ is not divisible by a prime of the form $4k+1$, and any prime divisors of $w$ of the form $4k+3$ occurs to an even power, and $k$ is odd. – André Nicolas Oct 2 '15 at 19:29
• Thank you very much sir, :). I googled for 35-40 minutes fruitlessly and couldn't find the complete answer. – guest123456 Oct 2 '15 at 19:38
• You are welcome. Fundamentally, the only exceptions to the $4k+1$ rule are given by $1^2+1^2=2$ and its close relatives. – André Nicolas Oct 2 '15 at 19:43

If a square is divisible by a prime $p$ with $p \equiv 1 \pmod 4,$ then it can also be written as two nonzero squares added. Begin with the Pythagorean triple $(u,v, p^2)$ and then multiply throughout by the remaining factor of your original square.

so, say your square is $25 w^2.$ Note $3^2 + 4^2 = 25.$ Then $(3w)^2 + (4w)^2 = 25 w^2$

From comments: given some $n^2,$ where the only prime factors of $n$ are either $2$ or $q \equiv 3 \pmod 4,$ then we cannot express $n^2 = s^2 + t^2$ with both $s,t \neq 0$ integers.

• Do you mean that for perfect squares having prime factors of form $4k+3$ can't be represented as sum of $2$ squares? – guest123456 Oct 2 '15 at 19:26
• @guest123456, if those are the only prime factors, yes. – Will Jagy Oct 2 '15 at 19:27
• But $36$ has $2$ prime factors and only one of them is of the form $4k+3$. – guest123456 Oct 2 '15 at 19:29
• @guest123456 edited answer – Will Jagy Oct 2 '15 at 19:30

The set of sums of two squares is closed by multiplication via the formula $$(a^2+b^2)(c^2+d^2)=(ac+bd)^2+(ad-bc)^2$$ Here, since $2=1+1$ you have $36=3^2(1+1)(1+1)=3^2[(1+1)^2+(1-1)^2]$ hence the only representation is the trivial one $$36^2= 36^2+0^2$$

There are cases in which this representation is not unique.