# Perfect Squares!

A question was asked in a mental ability test yesterday.

Write four distinct numbers with these properties:
1. Sum of each pair is a perfect square.
2. Sum of all four is also a perfect squares.

Can you solve this?

• For number A, B, C, D do I interpret the taskcorrectly as: Find A, B, C, D such that (A+B), (A+C), (A+D), (B+C), (B+D), (C+D) and (A+B+C+D) are all perfect squares? – BmyGuest Jun 12 '16 at 9:54
• Might not be too late to add no-computers tag for the sake of purity – humn Jun 12 '16 at 10:11
• @humn Agreed, although doing a good algorithm to test all, is not as straight forward neither, considering there is no other constraint.. (Testing in complex space with 4 variables seems a bit harsh, f.e....) – BmyGuest Jun 12 '16 at 10:21
• Indeed, @BmyGuest, and it would be valuable to see if a program were to find multiple solutions (if nobody figures out the complete set by hand) – humn Jun 12 '16 at 10:24
• I also wonder what the smallest possible number(s) is. – Inazuma Jun 12 '16 at 12:23

## 9 Answers

Took a long time but worth it.

I got two answers.

Ist set can be:

-88,88,137,488

As:

-88+88 = 0, a perfect square
-88+137 = 49 = 7^2
-88+488 = 400 = 20^2
88+137= 225 =15^2
88+488 = 576 = 24^2
137+488 = 625 =25^2
and finally,
-88+88+137+488=625=25^2

2nd set

-88,344,1177,2792

As:

-88+344 = 256 = 16^2
-88+1177 = 1089 = 33^2
-88+2792 = 2704 = 52^2
344+1177 = 1521 = 39^2
344+2792 = 3136 = 56^2
1177+2792 = 3969 =63^2
and
-88+344+1177+2792=4225 = 65^2

It may be

Since it is mental arithmetic and no restrictions.
$3, -3, 4i, -4i$

since:

a) $3 -3 =0$
b) $3 + 4i = (2 + i)(2 + i)$
c) $3 - 4i = (2 - i)(2 - i)$
d) $-3 + 4i = (1 + 2i)(1 + 2i)$
e) $-3 - 4i = (1 - 2i)(1 - 2i)$
f) $4i - 4i = 0$

and also:

$3 - 3 + 4i - 4i =0$

• Great, I should have thought about it(complex numbers) during test. Those two hours passed too fast. – ABcDexter Jun 12 '16 at 13:32
• I was thinking of complex numbers, too. But is your solution valid by the definition of 'perfect square'? (2-i) is not an integer... – BmyGuest Jun 12 '16 at 13:44
• Good point BmyGuest! My answer is not valid! – Tom Jun 12 '16 at 14:06
• @BmyGuest - wikipedia's a little inaccurate, a "perfect square" in integers is as described, but you can have a "perfect square" in other integral domains. The ones given by Tom are in the Gaussian Integers. See here: en.wikipedia.org/wiki/… – Glen O Jun 12 '16 at 16:39
• @GlenO thanks. Always good to learn something new. – BmyGuest Jun 12 '16 at 17:18

Below is a way to construct many solutions to the problem:

It's easy to see that we can write:
$A = (a^2+b^2-d^2)/2$
$B = (a^2-b^2+d^2)/2$
$C = (d^2+b^2-a^2)/2$
$D = c^2+(d^2-a^2-b^2)/2$
where
$e^2+b^2 = f^2+a^2 = d^2+c^2 = g^2$

So we need square numbers that satisfy this equation, and can then find appropriate values of $A$, $B$, $C$, and $D$. Note that the total number of odd values amongst $a$, $b$, and $d$ must be even (zero or two). So we need to find a square number that can be expressed as a sum of two squares in at least three different ways. We can achieve this by using complex numbers for evaluation.

Consider $125^2$. Now, we can express this in the form $5\times5^2\times5^3$. Noting that $5 = 1^2+2^2$, $5^2=3^2+4^2$, and $5^3=11^2+2^2$, we can find appropriate pairs by evaluating

$±(1+2i)(3±4i)(11±2i)$

which has values $75-100i$, $117+44i$, and $35+120i$ (the fourth case gives 125). So if we let
$a=75$
$b=44$
$c=120$
$d=35$
$e=117$
$f=100$
$g=125$

Then we get
$A = 3168$
$B = 2457$
$C = −1232$
$D = 11232$

Note that we can choose other products, to get different sets of values. For instance, ev3commander's first solution comes from $325^2 = 5^4\times13^2$, which can be written as $325^2 = 5\times65\times325$, with $5=1^2+2^2$, $65=1^2+8^2$, and $325=1^2+18^2$.

ev3commander's second solution comes from $65^2 = 5^2\times13^2 = 5\times13\times65$, with $5=1^2+2^2$, $13=2^2+3^2$, and $65=4^2+7^2$.

wrangler's solution comes from $25^2 = 5\times5\times25$, with $5=1+2^2$ and $25=3^2+4^2$.

• If this is secretly a computer solution, you have a brilliant computer! – humn Jun 12 '16 at 16:44
• "It's easy to see that we can write" - we have very different definitions of easy – Holloway Jun 12 '16 at 22:17
• @Holloway - it's just a matter of very basic algebra. Start with writing out, for instance, A+B=a^2, A+C=b^2, A+D=c^2, and B+C=d^2. These four are enough to define A, B, C, and D. Continue with B+D=e^2, C+D=f^2, and A+B+C+D=g^2, and you get the sum-of-squares relationships, too. – Glen O Jun 13 '16 at 4:56
• Wow, that is beautiful solution. What a shame I gave up so early. – BoltKey Jun 14 '16 at 8:28

Here we can have...

$a+b=38025=195^2$
$a+c=15625=125^2$
$a+d=8281=91^2$
$c+d=67600=260^2$
$b+d=90000=300^2$ $b+c=97344=312^2$
$a+b+c+d=38025+67600=15625+90000$
$=8281+97344=105625=325^2$

Numbers:

$a= -21847$
$b=59872$
$c=37472$
$d=30128$

seriously no computers, besides posting this. I did all this work on paper. It's possible.

• +1. a+b+c+d here does not equal a perfect square (though it seems all the other combinations do) – Inazuma Jun 12 '16 at 11:08
• my calculation for d was wrong. Fixing... – ev3commander Jun 12 '16 at 11:12
• @Inazuma, a+b+c+d=105625=325^2… – ev3commander Jun 12 '16 at 11:17
• Many brownie points to you – Inazuma Jun 12 '16 at 11:19
• Your calculations are perfect. (edited a bit) – ABcDexter Jun 13 '16 at 8:56
• Before continuing, let me say we have some trivial answers, like $a=b=c=d=0$ or $a=b=0, c=3^2, d=4^2$. But I am looking for an answer with no zero values.

Since we have four integers say, $a$, $b$, $c$, and $d$. We have 6 pairs of them, $$A_1=a+b=A^2\\ A_2=a+c=B^2\\ A_3=a+d=C^2\\ E_3=b+c=D^3\\ E_2=b+d=E^2\\ E_1=c+d=F^2$$

as you may easily see, if $a+b+c+d$ be a square, say $G^2$, the number should be presented as sum of two square in more than 2 different ways.

$$G^2=a+b+c+d=A_1+E_1=A_2+E_2=A_3+E_3$$

Since $5$ and $13$ are the smallest primes of the form $4k+1$, therefor their multiplication, $65$ is the smallest number in which its square could be shown in more than two ways as sum of two squares. so $G=65$, and $G^2=4225$.

Now, lets remember $65^2$ could be written as sum of two square in 4 different ways: $$65^2=4225\\ =256+3969=16^2+63^2\\ =625+3600=25^2+60^2\\ =1089+3136=33^2+56^2\\ =1521+2704=39^2+52^2$$

Since, I am whishing to find smallest answer for the problem, I should find which 3 (out of the 4 possible) pairs of square shall I chose.

Whitout further ado, let me show the answers $$a=-495\\ b=1120\\ c=1584\\ d=2016$$

I found them by solving the following linear equation.

$$\pmatrix{1 & 1 & 0 & 0 \\ 1 & 0 & 1 & 0 \\ 1 & 0 & 0 & 1 \\ 1 & 1 & 1 & 1 }\times \pmatrix{a \\ b \\ c \\ d}=\pmatrix{A_1 \\ A_2 \\ A_3 \\ 65^2}$$ By selecting $A_1=625$, $A_2=1089$, and $A_3=1521$.

Happy 2016! I bet no one can find a set of 4 nontrivial value each of which have an absolute value smaller than $2016$. ☺

• 1. I suppose you didn't see my answer first, right? 2. @wrangler already made a solution with all numbers in range (-2016, 2016) – ev3commander Jun 12 '16 at 19:21
• "some trivial answers" - they're ruled out anyway by the distinct number rule. – Holloway Jun 12 '16 at 22:20
• +1 This is by far the easiest, most thorough answer to understand. There are lots of other answers, but this is the only one which clearly shows how you did it without a use of a computer. – Inazuma Jun 12 '16 at 22:27
• This answer can be improved by explaining significance of the 4k+1 form of a prime number, as well as by demonstrating how to find (16,63), (25,60), (33, 56), (39, 52) pairs without computer. The latter mentioned in passing in Glen's answer. – Andrew Savinykh Jun 13 '16 at 7:54
• "I bet no one can find a set of 4 nontrivial value each of which have an absolute value smaller than 2016"...seriously?? View my answer – wrangler Jun 13 '16 at 10:13

One solution (if these numbers do not have to be positive, but OP said 'no constraints'). Also interpreting 'each pair' as in two separate pairs, i.e. (A, B) and (C,D) but not (A,C) or (B,D):

$-x, x, y, -y$

Then:

$-x + x = 0 = 0^2$
$-y + y = 0 = 0^2$
$-x + x -y + y = 0 = 0^2$
where $x \neq y.$

I am going to see if I can find a more interesting combination, however.

• Shame on the anonymous down voter. – Inazuma Jun 12 '16 at 10:08
• Didn't vote, but I guess the DV voted after the clarification above, which makes your answer invalid. Hence downvote. (It is not a good answer.) – BmyGuest Jun 12 '16 at 10:22
• Please don't argue over the votes, and show me the Maths to do it. I'd love to get some Pythagorean triples which fit into this system. P.S I upvoted O:) – ABcDexter Jun 12 '16 at 10:39
• @ev3commander Yes I already did. – ABcDexter Jun 13 '16 at 8:58

An epic one (kinda small) Also bonus for including 2016?

$a=-495$
$b=2016$ yay
$c= 1120$
$d=1584.$

Squares

$65^2 = 4225=33^2+56^2=25^2+60^2=39^2+52^2$
So, $a+d=1089=33^2$
$b+c=3136=56^2$
$a+c=625=25^2$
$b+d=3600=60^2$
$a+b=39^2=1521$
and $c+d=2704=52^2$.

• You are posting some good answers, once i cross check all will accept one of the above :) – ABcDexter Jun 12 '16 at 17:05

ANSWER OVERLOAD

-1980, 4480, 8064, 6336. Squares: 2500, 14400, 6084, 10816, 4356, 12544. squares of 50,120,78,104, 66 and 112. Total is 16900 or 130^2

-864, 2464, 3465, 2160. Squares are 1600, 5625, 2601,4624, 1296, 5929. Squares of 40;75;51;68;36;77. Total is 7225 or 85^2

-3419.5,4644.5; 5365.5, 9044.5. Squares are 1225;14400;1936;13689;5625; 10000. Squares of 35;120;44;117;75; 100. Total is 15625=125^2

• At last, fractions! – humn Jun 12 '16 at 23:33

Why is everyone using large numbers? A simple solution is:

1, 8, 8, 8

You have sums for pairs:

9 & 16

while for all of the numbers is:

25

• the Q says 'distinct' – JonMark Perry Jun 14 '16 at 12:35
• As Jon states it, the problem was to find distinct numbers. The "solution" (1,8,8,8) is too obvious. – ABcDexter Jun 14 '16 at 14:27