I'm currently taking a course in number theory and we've just seen that any number can be written as the sum of the 4 squares, and that numbers can be written as the sum of 3 if they aren't of a certain form.
The notes gave an example using 2024
$2024=44^2+4^2+6^2+6^2$ and then leaves finding if its possible to find a sum of 3 as an exercise.
My first question is if there is a systematic way to find some 4 numbers such that you have $n=x^2+y^2+z^2+w^2$ for any $n$ you pick, for smaller numbers anyway.
As to the exercise, i know the sums of 3 exist since 2024 is not of the form $4^a(8b+7)$, and after some brute force guessing i've found 8,14,42 and 10,30,32 as triples that work. But this was me just plugging in values and seeing if it worked, is there a better way of finding these triples? I've had some ideas along of the lines if you can find a sum of 4 such that 2 of them are in a Pythagorean triple, but this doesn't seem to help much because i still have to find the sum of 4.
For four squares, a somewhat systematic way to go is find the prime factorization and then reduce to representing each such prime as a sum of four squares. For example, $2024 = 2^3 \cdot 11 \cdot 23$. We have $11 = 3^2 + 1^2 + 1^2 + 0^2$ and $23 = 3^2 + 3^2 + 2^2 + 1^2$. Then systematically use the identity (hope it's right; I'm multiplying quaternions in my head)
$$(a^2 + b^2 + c^2 + d^2)(x^2 + y^2 + z^2 + w^2) = (ax - by - cz - dw)^2 + (ay + bx + cw - dz)^2 + (az + cx + dy - bw)^2 + (aw + dx + bz - cy)^2$$ that shows that sums of four squares are closed under taking products.
(More systematic still, the Wikipedia article linked to by JMoravitz in a comment gives a reference to an algorithm due to Rabin and Shallitt for finding the four squares, but I've not looked at that.)