# writing $pq$ as a sum of squares for primes $p,q$

Let $p$ and $q$ be distinct primes congruent to $1$ mod $4$. How many ways are there to write $pq$ as a sum of squares?

I know that any prime $p\equiv 1\pmod 4$ can be written uniquely as a sum of squares and $pq\equiv 1\pmod 4$ but $pq$ is not a prime so I'm stuck.

• There are just two ways, via the identity (a^2+b^2)(c^2+d^2) = (ad+bc)^2+(ac-bd)^2. (Although come to think of it I can't come up with an elementary explanation why there are just the two! The way I can think of involves the Gaussian integers.) – John Brevik Mar 6 '15 at 16:17
• May I ask is the sum of squares limited to two distinct integers? Because if $p=5$ and $q=17$ we can have $5\times17=85=4+81=36+49=1+4+16+64$, but I am not sure if the last expression is accepted or not. – LaBird Mar 6 '15 at 16:23
• I think you can get all you want to know from here. (especially from (15) to (18), I guess.) – mathlove Mar 6 '15 at 16:27
• I think that "sum of squares" is here intended to mean "sum of two squares." – André Nicolas Mar 6 '15 at 16:29
• See en.wikipedia.org/wiki/Brahmagupta–Fibonacci_identity. – lhf Mar 6 '15 at 19:20

Since $n$ can be written as a sum of two squares in a number of ways that depends on how many ways there are to split $n$ as: $$n = z\bar{z} = (a-bi)(a+bi)$$ over $\mathbb{Z}[i]$, and the latter is an Euclidean domain hence a UFD, it follows that for any $n\in\mathbb{N}$:
$$\#\{(a,b)\in\mathbb{Z}^2:a^2+b^2= n\} = 4(\chi_4*1)(n) = 4\left(d_1(n)-d_3(n)\right)$$ where $d_1(n)$ is the number of divisors of $n$ of the form $4k+1$ and $d_1(n)$ is the number of divisors of $n$ of the form $4k+3$. If $p$ and $q$ are primes of the form $4k+1$, it follows that: $$\#\{(a,b)\in\mathbb{N}^2:a^2+b^2=pq\} = \color{red}{4}.$$ These representations can be recovered from Lagrange's identity: $$(a^2+b^2)(c^2+d^2) = (ac-bd)^2+(ac+bd)^2.$$ For instance, let we assume $p=13$ and $q=41$. Then: $$p = 2^2 + 3^2,\qquad q=4^2+5^2$$ and $pq=13\cdot 41=533$ can be written as a sum of two squares in the following ways: $$pq = 2^2 + 23^2 = 7^2 + 22^2$$ since $2\cdot 4+3\cdot 5=23$ and $2\cdot 5+3\cdot 4=22$.