Sum of two squares theorem

number theorysums-of-squares

I am working on the problem: I need to quickly check if positive number $n$ can be expressed as $n^2=a^2+b^2$. I found this theorem: https://en.wikipedia.org/wiki/Sum_of_two_squares_theorem

But it seems I am missing something. For example number $4$ falls under theorem condition: its prime decomposition doesn't have any prime $p\equiv 3{\pmod {4}}$. But $4$ cannot be expressed as sum of 2 squares.

Best Answer

In the theorem $a,b$ have to be integers and don't have to be nonzero. So in your example: $4=2^2+0^2$.

So the theorem doesn't really help in your case. $n^2=n^2+0^2$ but that doesn't help you much, since I assume that you have additional assumptions on $a,b$, like for example that they should both be nonzero.

Related Question