Sum of one, two, and three squares

If a square $n^2$ can be written as the sum of two nonzero squares as well as the sum of three nonzero squares, then can we conclude that it can be written as the sum of any number of nonzero squares up to $n^2 - 14$ nonzero squares?

Example: $13^2 = 12^2 + 5^2 = 12^2 + 4^2 + 3^2$. But also $13^2 = 11^2 + 4^2 + 4^2 + 4^2$ and $13^2 = 12^2 + 4^2 + 2^2 + 2^2 + 1^2$ etc up to $13^2 = 3^2 + 2^2 + 2^2 + 1^2 + .. + 1^2$.


Solution 1:

It is true.

All positive integers that are not the sum of four nonzero squares are known, see FOUR and LAGRANGE. These are the eight odd number $1,3,5,9,11,17,29,41$ and the infinite families $2 \cdot 4^t, \; \; 6 \cdot 4^t, \; \; 14 \cdot 4^t.$ Out of the list, the squares are $1,9;$ of course $1$ is not the sum of two or three nonzero squares, while $9=4+4+1$ but is not the sum of two nonzero squares. This gives a quick and dirty way to show 1,2,3 nonzero squares implies 4 nonzero squares. A more elegant method, by Thomas Andrews, is in comment above.

All numbers, square or not, larger than 33 are the sum of five nonzero squares, see FIVE. All numbers, square or not, larger than 19 are the sum of six nonzero squares, see SIX.

Now, we have some $n^2 \geq 36, $ and we are told that $n^2$ is also the sum of two nonzero squares and of three nonzero squares. ThomasAndrews shows above how $n^2$ is the sum of four nonzero squares. So far, we have 1,2,3,4,5,6 covered.

Now, take any integer $M$ with $ 20 \leq M < n^2.$ We are told that $M$ is the sum of six nonzero squares. Then add in $n^2 - M$ copies of 1. The result is a summation of $n^2$ as $n^2 - M + 6$ nonzero squares. Here $$ 6 < n^2 - M + 6 \leq n^2 - 14. $$

The numbers up to 100,000 that are nonzero squares, and are also the sum of two nonzero squares and of three nonzero squares are

         169 = 13^2
         225 = 3^2 * 5^2
         289 = 17^2
         625 = 5^4
         676 = 2^2 * 13^2
         841 = 29^2
         900 = 2^2 * 3^2 * 5^2
        1156 = 2^2 * 17^2
        1225 = 5^2 * 7^2
        1369 = 37^2
        1521 = 3^2 * 13^2
        1681 = 41^2
        2025 = 3^4 * 5^2
        2500 = 2^2 * 5^4
        2601 = 3^2 * 17^2
        2704 = 2^4 * 13^2
        2809 = 53^2
        3025 = 5^2 * 11^2
        3364 = 2^2 * 29^2
        3600 = 2^4 * 3^2 * 5^2
        3721 = 61^2
        4225 = 5^2 * 13^2
        4624 = 2^4 * 17^2
        4900 = 2^2 * 5^2 * 7^2
        5329 = 73^2
        5476 = 2^2 * 37^2
        5625 = 3^2 * 5^4
        6084 = 2^2 * 3^2 * 13^2
        6724 = 2^2 * 41^2
        7225 = 5^2 * 17^2
        7569 = 3^2 * 29^2
        7921 = 89^2
        8100 = 2^2 * 3^4 * 5^2
        8281 = 7^2 * 13^2
        9025 = 5^2 * 19^2
        9409 = 97^2
       10000 = 2^4 * 5^4
       10201 = 101^2
       10404 = 2^2 * 3^2 * 17^2
       10816 = 2^6 * 13^2
       11025 = 3^2 * 5^2 * 7^2
       11236 = 2^2 * 53^2
       11881 = 109^2
       12100 = 2^2 * 5^2 * 11^2
       12321 = 3^2 * 37^2
       12769 = 113^2
       13225 = 5^2 * 23^2
       13456 = 2^4 * 29^2
       13689 = 3^4 * 13^2
       14161 = 7^2 * 17^2
       14400 = 2^6 * 3^2 * 5^2
       14884 = 2^2 * 61^2
       15129 = 3^2 * 41^2
       15625 = 5^6
       16900 = 2^2 * 5^2 * 13^2
       18225 = 3^6 * 5^2
       18496 = 2^6 * 17^2
       18769 = 137^2
       19600 = 2^4 * 5^2 * 7^2
       20449 = 11^2 * 13^2
       21025 = 5^2 * 29^2
       21316 = 2^2 * 73^2
       21904 = 2^4 * 37^2
       22201 = 149^2
       22500 = 2^2 * 3^2 * 5^4
       23409 = 3^4 * 17^2
       24025 = 5^2 * 31^2
       24336 = 2^4 * 3^2 * 13^2
       24649 = 157^2
       25281 = 3^2 * 53^2
       26896 = 2^4 * 41^2
       27225 = 3^2 * 5^2 * 11^2
       28561 = 13^4
       28900 = 2^2 * 5^2 * 17^2
       29929 = 173^2
       30276 = 2^2 * 3^2 * 29^2
       30625 = 5^4 * 7^2
       31684 = 2^2 * 89^2
       32400 = 2^4 * 3^4 * 5^2
       32761 = 181^2
       33124 = 2^2 * 7^2 * 13^2
       33489 = 3^2 * 61^2
       34225 = 5^2 * 37^2
       34969 = 11^2 * 17^2
       36100 = 2^2 * 5^2 * 19^2
       37249 = 193^2
       37636 = 2^2 * 97^2
       38025 = 3^2 * 5^2 * 13^2
       38809 = 197^2
       40000 = 2^6 * 5^4
       40804 = 2^2 * 101^2
       41209 = 7^2 * 29^2
       41616 = 2^4 * 3^2 * 17^2
       42025 = 5^2 * 41^2
       43264 = 2^8 * 13^2
       44100 = 2^2 * 3^2 * 5^2 * 7^2
       44944 = 2^4 * 53^2
       46225 = 5^2 * 43^2
       47524 = 2^2 * 109^2
       47961 = 3^2 * 73^2
       48400 = 2^4 * 5^2 * 11^2
       48841 = 13^2 * 17^2
       49284 = 2^2 * 3^2 * 37^2
       50625 = 3^4 * 5^4
       51076 = 2^2 * 113^2
       52441 = 229^2
       52900 = 2^2 * 5^2 * 23^2
       53824 = 2^6 * 29^2
       54289 = 233^2
       54756 = 2^2 * 3^4 * 13^2
       55225 = 5^2 * 47^2
       56644 = 2^2 * 7^2 * 17^2
       57600 = 2^8 * 3^2 * 5^2
       58081 = 241^2
       59536 = 2^4 * 61^2
       60025 = 5^2 * 7^4
       60516 = 2^2 * 3^2 * 41^2
       61009 = 13^2 * 19^2
       62500 = 2^2 * 5^6
       65025 = 3^2 * 5^2 * 17^2
       66049 = 257^2
       67081 = 7^2 * 37^2
       67600 = 2^4 * 5^2 * 13^2
       68121 = 3^4 * 29^2
       70225 = 5^2 * 53^2
       71289 = 3^2 * 89^2
       72361 = 269^2
       72900 = 2^2 * 3^6 * 5^2
       73984 = 2^8 * 17^2
       74529 = 3^2 * 7^2 * 13^2
       75076 = 2^2 * 137^2
       75625 = 5^4 * 11^2
       76729 = 277^2
       78400 = 2^6 * 5^2 * 7^2
       78961 = 281^2
       81225 = 3^2 * 5^2 * 19^2
       81796 = 2^2 * 11^2 * 13^2
       82369 = 7^2 * 41^2
       83521 = 17^4
       84100 = 2^2 * 5^2 * 29^2
       84681 = 3^2 * 97^2
       85264 = 2^4 * 73^2
       85849 = 293^2
       87025 = 5^2 * 59^2
       87616 = 2^6 * 37^2
       88804 = 2^2 * 149^2
       89401 = 13^2 * 23^2
       90000 = 2^4 * 3^2 * 5^4
       91809 = 3^2 * 101^2
       93025 = 5^2 * 61^2
       93636 = 2^2 * 3^4 * 17^2
       96100 = 2^2 * 5^2 * 31^2
       97344 = 2^6 * 3^2 * 13^2
       97969 = 313^2
       98596 = 2^2 * 157^2
       99225 = 3^4 * 5^2 * 7^2
jagy@phobeusjunior:~$