Integer as Sum of Polygonal Numbers

Theorem
Let $n \in \Z_{>0}$ be a (strictly) positive integer.

Then $n$ is:
 * $(1): \quad$ Either triangular or the sum of $2$ or $3$ triangular numbers
 * $(2): \quad$ Either square or the sum of $2$, $3$ or $4$ square numbers
 * $(3): \quad$ Either pentagonal or the sum of $2$, $3$, $4$ or $5$ pentagonal numbers
 * and so on.

Proof
For $(1)$ we have Integer is Sum of Three Triangular Numbers.

For $(2)$ we have Lagrange's Four Square Theorem.

For each $m \ge 3$, we prove that $n$ is the sum of at most $m + 2$ $\paren {m + 2}$-gonal numbers.

We choose $\paren {m + 2}$-gonal numbers since they have the nice closed form:


 * $\map P {m + 2, k} = \dfrac m 2 \paren {k^2 - k} + k$

For $n < 116 m$ the result is shown here.

So we consider the numbers with $n \ge 116 m$.

Define:


 * $I = \openint {\dfrac 2 3 + \sqrt {8 \paren {\dfrac n m} - 8} } {\dfrac 1 2 + \sqrt {6 \paren {\dfrac n m} - 3}}$

$(*)$ For $\frac n m \ge 116$, the length of $I$ is greater than $4$.

Then it must contain at least $2$ consecutive odd integers.

Let $b_1, b_2$ be those consecutive odd integers.

Since $b_1 + m - 1 = b_2 + m - 3$:

The set $\set {b + r: b \in \set {b_1, b_2}, r \in \set {0, 1, \dots, m - 2}}$ contains a complete residue system modulo $m$.

Hence one can choose some $b, r$ and write $n \equiv b + r \pmod m$.

Define:
 * $a = 2 \paren {\dfrac {n - b - r} m} + b = \paren {1 - \dfrac 2 m} b + 2 \paren {\dfrac {n - r} m}$

Since $m \divides n - b - r$ and $b$ is Odd, $a$ is an odd integer.

We must show the following:

$(**)$ If $b \in I$, $a, b$ satisfy:
 * $b^2 < 4a$
 * $3 a < b^2 + 2 b + 4$

Then by Integer as Sum of Polygonal Numbers/Lemma, we can write:


 * $a = s^2 + t^2 + u^2 + v^2$
 * $b = s + t + u + v$

For nonnegative integers $s, t, u, v$.

Thus:

Since $r \le m - 2$, the above expression comprises at most $m + 2$ $\paren {m + 2}$-gonal numbers.

Now we verify our previous claims $(*)$ and $(**)$.

$(*)$
We need to show that $\paren {\dfrac 2 3 + \sqrt {8 \paren {\dfrac n m} - 8} } - \paren {\dfrac 1 2 + \sqrt {6 \paren {\dfrac n m} - 3}} > 4$ when $\dfrac n m \ge 116$.

Let $x = \dfrac n m - 1$.

Then:

To simplify calculations, we consider:

which is true when $x \ge 115$.

Thus this condition is satisfied when $\frac n m \ge 116$.

$(**)$ - $b^2 < 4 a$

 * $b^2 - 4 a = b^2 - 4 \paren {1 - \dfrac 2 m} b - 8 \paren {\dfrac {n - r} m}$

By the Quadratic Formula, $b^2 - 4 a < 0$ when $b$ is between:

Observing the term in the square root, we have:
 * $2 - \dfrac 4 m - \sqrt {\paren {2 - \dfrac 4 m}^2 + 8 \paren {\dfrac n m} - 8 \paren {\dfrac r m} } < 0$

Showing that first inequality is satisfied.

$(**)$ - $3 a < b^2 + 2 b + 4$

 * $b^2 + 2 b + 4 - 3 a = b^2 - \paren {1 - \dfrac 6 m} b - 6 \paren {\dfrac {n - r} m} + 4$

By the Quadratic Formula, $b^2 + 2 b + 4 - 3 a > 0$ when $b$ is greater than:

Showing that second inequality is satisfied by any $b > \dfrac 1 2 + \sqrt {6 \paren {\dfrac n m} - 3}$.

All statements are checked, thus the result follows.