# $2017$ as the sum of two squares

Write the prime $2017$ as the sum of two squares

$2017$ can be written as the sum of two squares because it is a prime of the form $p\equiv 1\ ($mod $4)$

Using an appropriate algorithm find the two numbers that, when squared, add to the total of $2017$

• Brute force this one – saadtaame Jan 30 '14 at 13:56
• Is this a contest problem from the year 2017? – Sid Jan 30 '14 at 14:04
• – lhf Jan 30 '14 at 15:26

Possible last digits of any square number :$$0,1,4,5,6,9$$ Possible combinations that can give perfect squares which end in $7$ are:$$(1,6)$$ Find the numbers whose squares are ending with $1,6$ and less than $2017$.

List of such numbers whose squares end in $1$ are : $1,9,11,19,21,29,31,39,41$. Check if any of the squares of these numbers when subtracted from $2017$, gives you a perfect square. $$2017 - 1^2 = 2017 - 1 = 2016$$ $$2017 - 9^2 = 2017 - 81 = 1936 = 44^2$$ $$2017 - 11^2 = 2017 - 121 = 1896$$ $$....$$ $$2017 - 41^2 = 2017 - 1681 = 336$$

Find all the possible pairs, one such pair being $(9,44)$.After going through all the above mentioned cases, you can eventually conclude that $(9,44)$ is the only pair which satisfies the given condition.

• One can conclude there is only 1 pair before even attacking the problem: since $2017$ is prime there can't be another pair (up to changing signs and switching). – punctured dusk Jan 30 '14 at 17:58

This wouldn't be too difficult to figure out. Write a list of all squares less than 2017. Then for each square on the list $n^2$ see if $2017 - n^2$ is also on the list. 2017 is small enough that this "algorithm" should work pretty fast.

Hint The quadratic residues $\pmod{9}$ are $0,1,4,7$. There is only one way to write $1 \pmod{9}$ as the sum of two quadratic residues.

About 200 years ago, Jacobi would have known, and shown, that the number of representing 2017 as a sum of two squares is exactly 8.

More generally, for a positive integer $n$, let $r_2(n)$ denote the number of representations of $n$ as a sum of two squares of integers; for example, $r_2(5) = 8$, since $5 = 2^2 + 1^2 = (-2)^2 + 1^2 = 2^2 + (-1)^2 = (-2)^2 + (-1)^2 = 1^2 + 2^2 = 1^2 + (-2)^2 = (-1)^2 + 2^2 = (-1)^2 + (-2)^2.$ Let also $d_1(n)$ denote the number of positive divisors of $n$ of the form $4k+1$ and $d_3(n)$ the number of positive divisors of $n$ of the form $4k+3$. Jacobi's Formula is $$r_2(n) = 4(d_1(n) - d_3(n)) .$$ Since 2017 is prime, and equal to $4 \times 504 + 1$, we have immediately $r_2(2017) = 4(2-0) = 8$. Easy to check: $2017 = (44)^2 + 9^2 = (-44)^2 + 9^2 = \cdots$.

One out of many possible references for a proof of the formula of Jacobi: Theorem 3.2.1 in Bruce C. Berndt, Number Theory in the Spirit of Ramanujan, Student Mathematical Library 34, Amer. Math Soc. 2006.