Firstly, we check if 6519 ≡ 7 (mod 8), because that tells us in advance whether three squares can possibly be enough.
Squares (mod 8) can only be 0, 1 or 4 :
- Even numbers are 0 or 4 (mod 8)
- Odd numbers are 1 (mod 8)
Three squares can never give 7, because a square leaves a remainder of only 0, 1 or 4 when divided by 8. So when you add three squares, you’re really adding three numbers picked from {0, 1, 4} to find the remainder. There are only 10 ways to pick them:
picks 0+0+0; sum 0; remainder (mod 8) 0
picks 0+0+1; sum 1; remainder (mod 8) 1
picks 0+0+4; sum 4; remainder (mod 8) 4
picks 0+1+1; sum 2; remainder (mod 8) 2
picks 0+1+4; sum 5; remainder (mod 8) 5
picks 0+4+4; sum 8; remainder (mod 8) 0
picks 1+1+1; sum 3; remainder (mod 8) 3
picks 1+1+4; sum 6; remainder (mod 8) 6
picks 1+4+4; sum 9; remainder (mod 8) 1
picks 4+4+4; sum 12; remainder (mod 8) 4
7 never appears in the last column. If we add any three values from {0, 1, 4} the possible results (mod 8) are 0, 1, 2, 3, 4, 5 and 6, but never 7. So three squares can’t work.
Now, we choose the first square, a². The remainder 6519 − a² must be a sum of three squares.
If is a multiple of 4, (6519 − a²) (mod 8) gives us a remainder of 7, which is doesn’t works.
If is 2 more than a multiple of 4, (6519 − a²) (mod 8) gives us a remainder of 3, which works.
If is odd, (6519 − a²) (mod 8) gives us a remainder of 6, which works.
We start near √6519 ≈ 80.7, but we skip multiples of 4, because they leave a remainder that is still 7 (mod 8).
So, a = 80 is a multiple of 4: we skip it.
We choose a = 78, because 78^2= 6084, and 6519 – 6084 give us 435 and 435 (mod 8) = 3
If we look again at the table of three picks from {0, 1, 4}, only one row gives 3 : 1 + 1 + 1
And which squares leave remainder 1? Only the odd ones, because even squares leave 0 or 4. So if 435 = b² + c² + d², then b, c and d must all be odd.
So, we have a, which is 78.
To find b, we split 435 into three odd squares. We subtract odd squares b² from the top and we check whether what’s left is a sum of two squares.
The largest odd square below 435 is 361, and 361 =19^2.
Now, 435 – 361 = 74.
Is 74 a sum of two squares ? Yes it is.
The direct way to know if is a sum of two squares is subtracting squares from 74 and see whether a square is left. The larger of the two must be at least half of 74, which is 37, so only 7 and 8 are possible:
- 74 − 64 = 10, not a square
- 74 − 49 = 25 = 5²
So 74 = 7² + 5² = 49 + 25
We finally write down the answer : 6519 = 78^2 + 19^2 + 7² + 5²
I was helpeb by IA. Any mistake is mine.