# Why is every positive integer the sum of 3 triangular numbers?

Why is every positive integer the sum of at most 3 triangular numbers ?

• You mean at most 3 triangular numbers, I suppose? Nov 18, 2014 at 23:39
• I consider 0 a triangular number so ...
– mick
Nov 18, 2014 at 23:40
• No, the title is correct. "At most 3 triangular numbers" would mean that there is no integer which is the sum of 4 triangular numbers. Nov 19, 2014 at 0:07
• Nov 19, 2014 at 4:14
• @Lucian Fermat's polygonal number theorem is much more general and harder then the eureka theorem. Its related yes. But the proof of the polygonal requires the eureka and four squares I think.
– mick
Nov 19, 2014 at 22:35

Every positive integer $$\equiv 3\mod{8}$$ can be written as a sum of three squares; see here for a proof (in fact, more integers than just those can be so written).

The result about triangular numbers follows from that result: let $$n>0$$; then $$8n+3$$ is a sum of three squares. From congruence conditions modulo $$4$$, it follows that each square is odd, so that $$8n+3 = (2x+1)^2 + (2y+1)^2 + (2z+1)^2 = 4x^2 + 4x + 4y^2 + 4y + 4z^2 + 4z + 3,$$ so that $$8n = 4x(x+1) + 4y(y+1) + 4z(z+1).$$ The result follows upon dividing through by $$8$$.

• there is a trick due to Aubry, about 1912, that proves that the sum of three squares integrally represents any integer that it rationally represents. This is in Serre's little book. Nov 19, 2014 at 3:00
• @WillJagy Yes, I've seen that. Looking at that book again, he goes on to give essentially the proof above for triangular numbers as well. But that observation does not simplify the three squares proof, unless I'm missing something. Nov 19, 2014 at 15:43
• In that paper I see on page 3 : (14) If p/q, then (5), (-m/p) = l. Im confused about that step. Plz explain. Thank you.
– mick
Nov 19, 2014 at 22:37
• @mick Equation (5), if $p\mid q$, says that $-m$ is a square mod $p$, which is $\left(\frac{-m}{p}\right) = 1$. Nov 19, 2014 at 22:52
• Oh yes ! @rogerl thank you ! +1
– mick
Nov 19, 2014 at 22:57