+0

# A couple of squares

0
119
1

How many pairs of squares, A and B, between 1 and 1,000,000 will satisfy the following equation? This is an assignment for our computer coding class. I realize that not many on this forum tackle question in computer programming. But any help from anybody would be greatly appreciated. Thank you very much.
A^2 + B^2 =1,863,702,780,625

Feb 17, 2019

#1
+1

I don't know what programming language you are learning. But, for this question, you would set up a simple search routine that would subtract A^2 or B^2 from the given number on the RHS and take its square root. If it returns an integer, then that is one number found. And so on....

In C++ the routine would look something like this:

n=1; a=(2#(1863702780625 - n^2);b=if(ceil(a) - floor(a)==0, goto3, goto5);c=(2#(1863702780625 - n^2);print"n=",n, "=",c;   n++;if(n<=1000000, goto1, discard=0;

With the above routine, my computer listed these numbers:

1 - 33292^2 + 1364769^2
2 -126945^2 + 1359260^2
3 -160055^2 + 1355760^2
4 -193060^2 + 1351455^2
5 -225960^2 + 1346345^2
6 -295008^2 + 1332919^2
7 -350175^2 + 1319500^2
8 -359639^2 + 1316952^2
9 -382249^2 + 1310568^2
10 -502460^2 + 1269345^2
11 -511560^2 + 1265705^2
12 -563745^2 + 1243340^2
13 -627039^2 + 1212652^2
14 -656425^2 + 1197000^2
15 -685412^2 + 1180641^2
16 -705628^2 + 1168671^2
17 -714000^2 + 1163575^2
18 -819105^2 + 1092140^2
19 -845495^2 + 1071840^2
20 -917112^2 + 1011241^2
21 -941500^2 + 988575^2
22 -965321^2 + 965328^2

Note: You have to be wary of duplicates!

Feb 17, 2019