# Thread: Sums of integers are squares

1. ## Re: Sums of integers are squares

By "getting an answer", I just mean the program finishes. I seem to be good at being unclear . Anyway, getting the solutions is trivial if we already have the triplets, at least with my algorithm. The triplets are stored in a vector and end up sorted in the end so I just have to check if 3 consecutive triplets have the same sum.

I've discovered that the problem is about equivalent to finding the solutions to the Diophantine equation A^2+B^2+C^2 = 2D^2.
This is becuase (a+b)+(b+c)+(a+c) = 2(a+b+c). The sum of three squares is twice a square. My algorithm focuses on finding solutions to this equation. If the equation has at least three solutions for a given D, then we can get at least one set {a,b,c,d,e,f,g,h,i} that satisfies all conditions. I prefer not to go into how I'm getting the solutions, because it's still rather bad. I'd be interested if you can come up with an efficient way to do it.
Here is some of my program's output:

a+b+c < 10000
Solutions: 10
Triplets:77
Time: 0.005 seconds
a+b+c < 10000000
Solutions: 108450
Triplets:114388
Time: 6.126 seconds
a+b+c < 100000000
Solutions: 1141596
Triplets:1161121
Time: 630.096 seconds

This set of 18 triplets is also worthy of note, trusting that my program didn't make any mistakes. They all sum to the same square and meet the conditions a+b, a+c, b+c is square:

22800 23856 46369
22800 31024 39201
21736 33489 37800
15184 19041 58800
14625 38736 39664
14064 22800 56161
12369 33000 47656
10656 14625 67744
7176 16849 69000
6000 27489 59536
6000 42400 44625
4816 6000 82209
3025 6000 84000
3025 7176 82824
3025 16296 73704
3025 29016 60984
3025 41496 48504
609 22800 69616

There is a set of size 173 for a+b+c < 10,000,000

Sorry for taking up so much space. I tried to fit multiple triplets on a line but the forum seems to get rid of extra spaces so I can't separate them clearly.

2. ## Re: Sums of integers are squares

Originally Posted by browni3141
a+b+c < 10000
Solutions: 10
Hmmm...I get 9: for these squares:
2401, 6241, 7225, 7569(3 cases), 8281, 9025, 9604

Which other one do you get?

Page 2 of 2 First 12