<s>[INST] A problem I didn't know since high school algebra Determine all positive integers which can be written as a sum of two squares of integers. 
This is a problem I saw when I was in high school... 


*

*sum of two squares of integers can be (4k, 4k+1, 4k+2, but no 4k+3?)

 [/INST] Every integer $n$ can be expressed as $n=4k+r$ for $r=0,1,2,3$. $r$ is called the remainder after division by 4. Now $n^2 = (4k+r)^2 = 4^2k^2 + 8kr + r^2$.
If $r = 0$ then $r^2=0$. So $n^2=4k'$ for some $k'$.
If $r=1$ then $r^2=1$. So $n^2=4k'+1$ for some $k'$.
If $r=2$ then $r^2=4$. So $n^2=4k'$ for some $k'$.
If $r=3$ then $r^2 = 9 = 2\cdot 4 + 1$. So $n^2 = 4k'+1$ for some $k'$.
Thus the square of every integer can be expressed as $n^2 = 4k + r$ where $r=0$ or $r=1$.
Thus the sum of two squares can have the following remainders after division by 4:
$$1+1=2$$
$$1+0=1$$
$$0+0=0$$
Note that we cannot have a remainder of 3, since this has exhausted all the possibilities.

A neat thing that you can show with a bit of imaginary numbers is that the product of two numbers that are a sum of squares is again a sum of squares.
$$(n^2+m^2)(a^2+b^2)$$ $$= (n+im)(n-im)(a+ib)(a-ib)$$ $$= (an-bm+i(nb+ma))(an-bm-i(nb+ma))$$
$$=(an-bm)^2+(nb+ma)^2$$
Thus if we take $10=3^2+1$ and $8=2^2+2^2$ we can write $80$ as the sum of two squares:
$$80 = (6-2)^2+(6+2)^2 = 4^2 + 8^2.$$
</s>