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.

That is:
 * for all $k \ge 3$, $n$ is the sum of no more than $k$ polygonal numbers of order $k$.

Proof
First some lemmata:

Lemma 3
First note that Cauchy's Lemma (Number Theory) gives us:

Now we consider the numbered statements as asserted.

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$ polygonal numbers of order $m + 2$.

We choose to consider polygonal numbers of order $m + 2$, rather than $m$-gonal numbers, because the former have a neater closed form:


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

For $n < 116 m$ the result is shown in Lemma 1.

It remains to investigate the integers $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} }$

By Lemma 2:


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

Thus $I$ must contain at least $2$ consecutive odd integers.

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

Because $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 \paren {n - b - r}$ and $b$ is odd:
 * $a$ is an odd integer.

Since $b \in I$, from Lemma 3 we have:


 * $b^2 < 4 a$
 * $3 a < b^2 + 2 b + 4$

Then by Cauchy's Lemma (Number Theory), 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$ polygonal numbers of order $m + 2$.