I read something about how the possible digits of any square number is $0,1,4,5,6,9$ and that I could bash it out, but then that would take a lot of time. Is there any other way to to this problem?
-
1What do you know about Pythagorean Triples? – Brevan Ellefsen Mar 25 '17 at 03:09
-
The possible final digits can only be those digits. – Thomas Andrews Mar 25 '17 at 03:09
-
Pythagorean Triples are integers $a,b,c$ in the form $a^2$+$b^2$=$c^2$ – jonyoung2002 Mar 25 '17 at 03:13
-
That is correct. Do you know the parameterization of primitive Pythagorean triples? If not, Wikipedia is your friend. – Ross Millikan Mar 25 '17 at 03:14
-
First solve $u^2 + v^2 = 2017$ – Will Jagy Mar 25 '17 at 03:18
-
1OK. Looked it up. So what I would do is first write 2017 as the sum as 2 squares (9,44) and substitute those values for m and n. Then I would do $44^2$-$9^2$=a and $44$$9$2=b. – jonyoung2002 Mar 25 '17 at 03:20
-
1Got it! Thanks! – jonyoung2002 Mar 25 '17 at 03:21
-
To find non-zero $x,y\in \Bbb Z^+$ with $x^2+y^2=2017$: Note $2017 $ is prime so there is just one solution (up to interchanging $ x,y$). One of $x,y$ must be odd and the other even. So let $x=2m+1$ and $y=2n. $ Then $4n^2=y^2=2017-x^2=2017-(2m+1)^2=4(504-(m)(m+1)),$ so $n^2=504-(m)(m+1),$ which is even. So let $n=2k.$ Then $k^2 =\frac {n^2}{4}= 126-\frac {1}{4}m(m+1). $ This implies $4$ divides $m$ or $4$ divides $m+1.$ Also $m\le 22$ (as $(23)(24)/4=(23)(6)>126)$...This narrows it to $10$ possible values for $m.$ We are lucky with the 2nd-least one $m=4.$ – DanielWainfleet Jul 08 '19 at 01:55
4 Answers
By combining Fermat's theorem on sums of squares and the irreducible elements in the Gaussian integers $\mathbb{Z}[i]$ one can find the number of representations of an integer n(not necessarily a square) when in n's prime factorization all primes are congruent to 1 mod 4. We have the following method which gives the number of the representations and how to find them. Let:
$$n=p_{1}^{a_{1}}...p_{n}^{a_{n}}$$
Such that all $p_{k}$ are congruent to 1 mod 4. There are exactly $4(a_{1}+1)...(a_{n}+1)$ representations of n as a sum of squares. And these can be found by factorizing $p_{k}$ in the Gaussian integers as $p_{k}=(a+bi)(a-bi)$ and multiplying any combination made by taking $a_{n}$ guys from each $p_{k}$'s factorization.
For your specific problem, since 2017 is a prime congruent to 1 mod 4 by the formula above it can be written in 4x3=12 ways. 2017's factorization is: $$2017=(44+9i)(44-9i)$$ hence $$2017^2=(44+9i)^2(44-9i)^2$$ by picking any two guys(we use two picks since the others are the same) from the above representation you get all the answers except for changing signs and summands: $$1855+792i=(44+9i)(44+9i)$$ $$2017+(0)i=(44+9i)(44-9i)$$ So 6 of 12 solutions with all possible choices of signs are $2017^2=(\pm1855)^2+(\mp792)^2=(\pm2017)^2+0^2$. The other 6 solutions are made by changing the order of summands.
Note factorizing 2017 in the Gaussian integers is the same as finding the only two numbers such that $2017=a^2+b^2=44^{2}+9^{2}$ which still takes time since 2017 is a large prime, but is still easier than doing the same directly for 2017^2. Generally this method works better for small primes in factorizations.

- 69
All Pythagorean triples $(a,b,c)$, $a^{2}+b^{2}=c^{2}$, satisfy the formulas \begin{equation*} a=k(m^{2}-n^{2}),\quad b=2kmn,\quad c=k(m^{2}+n^{2}),\qquad m>n> 0,\quad k> 0. \end{equation*}
Since $c=2017=44^{2}+9^{2}$(see this answer), $k=1$. Then $m=44,n=9$, and \begin{eqnarray*} a &=&m^{2}-n^{2}=44^{2}-9^{2}= 1855, \\ b &=&2mn= 2(44)(9)= 792. \end{eqnarray*} The other solutions are found by allowing negative values or swapping $ a $ with $ b $. So $ a=\pm 1855, b=\pm 792$, $ a=\pm 792, b=\pm1855 $.

- 38,602
We can find a triple for any value of $C$, if it exists for a primitive, a double of a primitive, or a perfect square times a primitive by solving $C$ for $n$ and using a finite search of $m$ values to see which, if any, yield an integer $n$.
Given $C= m^2+n^2,\space n=\sqrt{C-m^2}$ where $\biggl\lceil\sqrt{\frac{C}{2}}\space\space\biggr\rceil \le m\le\bigl\lfloor\sqrt{C}\bigr\rfloor$.
For example, if $C=2017,$ $$n=\sqrt{2017-m^2}\text{ where } \biggl\lceil\sqrt{\frac{2017}{2}}\space\space\biggr\rceil=32 \le m\le\bigl\lfloor\sqrt{2017}\bigr\rfloor=44$$
In testing $32\le m \le 44$, we find that only $m=44$ yields an integer $(9)$.
$$f(44,9)=(1855,792,2017)$$

- 6,338
Another way of doing this is to write a computer program:
Python Program
c2 = 2017 * 2017
a = 1
b = 2017
while 1:
if a == b:
break
a2 = a * a
b2 = b * b
d2 = a2 + b2
if d2 > c2:
b = b - 1
continue
if d2 < c2:
a = a + 1
continue
if d2 == c2:
print('success',a,b)
a = a + 1
b = 2017
print('exit',a,b)
OUTPUT
success 792 1855
exit 1426 1426

- 11,366