I was going through Erich Friedman's "What's Special About This Number?" and there some numbers are classified based on the number of ways we can write them as sum of squares. I want to prove the following claim by Friedman:

129 is the smallest number that can be written as the sum of 3 squares in 4 ways.

Indeed, as given in Wikipedia, $$11^2+2^2+2^2 = 10^2+5^2+2^2 = 8^2+8^2+1^2 = 8^2+7^2+4^2 = 129$$ So what remains to prove is that this is the smallest such number.

Is it possible to write a proof for this fact using some insights along with brute force/cases? How can we solve this problem using only brute-force?

Also, since I know the proof of Legendre's three-square theorem. I am also curious to know:

How can we determine the number of ways we can write a non-negative integer which satisfies Legendre's three-square theorem as sum of three squares?

Edit1: Related discussions on MathOverflow:

Edit2: Related discussions on ComputerScience.SE

Edit3: Related discussions on Mathematics.SE

  • $\begingroup$ @TheGreatDuck nothing better possible? $\endgroup$ – rationalbeing Dec 22 '16 at 6:14
  • 2
    $\begingroup$ we can find some solutions, if not all, by solving some quadratic equations using triangular numbers as explained in the link below but I don't have the proof that we will find all of them: math.stackexchange.com/questions/2070691/… $\endgroup$ – user25406 Dec 24 '16 at 16:39
  • 1
    $\begingroup$ @user25406 this approach appears to be promising. $\endgroup$ – rationalbeing Dec 24 '16 at 18:27
  • 1
    $\begingroup$ There is the following formula for the number of representations of $n$ as a sum of two squares: $4 \sum_{m | n} \chi_4(n)$, where $\chi_4$ is the conductor of order 4. I wonder if this could be generalized to your question. $\endgroup$ – J Richey Feb 20 '17 at 7:28
  • 1
    $\begingroup$ I read this in a book on Sieve theory, though I can't seem to find the book. The formula comes from the connection between Dirichlet characters (which are related to the Legendre/Jacobi symbol) and sums of squares. $\endgroup$ – J Richey Feb 20 '17 at 11:09

For the system of equations.


Solutions can be parameterized.













It is interesting that such triples can be too much. The formula can be increased to any number. That is the same to write not only for 4 partitions, but for any number. The main thing that all the variables were not identical to each other.

  • 1
    $\begingroup$ Can you please give at least an outline of how one should write proof for 129 being smallest such number using this parametrization? $\endgroup$ – rationalbeing Dec 23 '16 at 8:14
  • 2
    $\begingroup$ @individ, can you please post your derivation or a link to it. I think it is important to show how you got this parametrization, especially to those among us (I am one of them) who don't have the knowledge to derive it for themselves. $\endgroup$ – user25406 Dec 23 '16 at 21:13

You can try something like:

check=new Array();
for (i=1;i<12;i++)
for (j=i;j<12;j++)
for (k=j;k<12;k++) {
if (!check[n]) check[n]=0;
for (a=0;a<check.length;a++)
if (check[a]>=4) console.log(a);

which proves $129$ is the smallest such number, followed by:


You can determine the number of representations by $3$ squares by subtracting squares from $N$, and using $\sum_\limits{x\le \sqrt{N}} r_2(N-x^2)$, where $r_2$ is the sum of (two) squares function.

  • $\begingroup$ Did you read the Edit1 above stating that these counting functions also count the number is permutations and sign changes (which I don't want)? $\endgroup$ – rationalbeing Feb 21 '17 at 6:27
  • $\begingroup$ somewhere there is a formula for sum of two squares where zeroes, sign and order aren't counted - for example 16 doesn't count, but I can't find it just now. $r_2$ is the best we've got at the moment I think for the number of such numbers. $\endgroup$ – JMP Feb 21 '17 at 6:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.