squares which are not the sum of a square and twice a triangular number I'm trying to determine conditions on integer squares which cannot be written as a square and twice a triangular [all numbers positive], i.e. integers $n \ge 1$ where there are no integers $a,b \ge 1$ such that
$$ n^2 = a^2 + b^2+b.$$
For example, $$9 = 1^2 + 8 = 2^2 + 5,$$ so it is such a number; however, $16=2^2 + (2 \cdot 6)$, so it is not.
This paper http://math.nju.edu.cn/~zwsun/111o.pdf claims a proof about numbers which cannot be written as the sum of a square and two [not necessarily equal] triangular numbers — I will try to adapt their proof if I can't find another.
Any references or hints on how to approach the problem would be appreciated.
Thanks!
Kieren.
 A: $n^2$ can be written as $a^2 + b^2 + b,$ with $a,b \geq 1,$ if and only if
$$  4 n^2 + 1   $$ is composite.
If $4 n^2 + 1$ is composite, it is the sum of two squares in a distinct manner,
$$  4 n^2 + 1 = 4 u^2 + (2v+1)^2. $$ Then
$$ n^2 = u^2 + v^2 + v.  $$
If $$ n^2 = a^2 + b^2 + b,$$ then
$$  4 n^2 + 1 = 4 a^2 + (2b+1)^2,  $$ has two distinct representations as the sum of two squares and hence is composite.
There is a very nice short article by John Brillhart about the relationship between multiple expressions of a number as the sum of two squares (or as any $m x^2 + n y^2$) and compositeness of that number. American Mathematical Monthly, December 2009, pages 928-931, title A Note on Euler's Factoring Problem. The first page of a follow-up article is visible at FIRST PAGE.
A: $4n^2+1=(2a)^2+(2b+1)^2$. So it really depends on whether $4n^2+1$ can be written as the sum of two squares in more than the trivial way. That happens exactly when $4n^2+1$ is composite.
So the squares that are not of this form are the ones for which $4n^2+1$ is prime.
A: In fact every odd square can be written as $n^2= 4T_{k} + a^2 + (a+1)^2$. Every odd square can be decomposed into:
$n^2 = [(n-1)/2 + (n+1)/2]^2$ with $(n-1)/2=4T_{k}$ and $(n+1)/2 = a^2 + (a+1)^2$ or equivalently $n^2 = (a+b)^2 = a^2 +2ab +b^2$.
Your example $9= 2^2 +5$ can in fact be rewritten as:
$9=(9-1)/2 + (9+1)/2 = 4 + 5 = (1+2)^2 = 4T_{1} + 1^2 + 2^2$
If you lump the two squares $(a^2 +b^2)=m$, then you will end up with:
$n^2= m + 4T_{k}$. This is truly a general result. But lumping the two squares into an integer doesn't make the two squares disappear. They are just hidden.
Let's consider another example $n^2=9^2=(4+5)^2= 4^2 +2*4*5 + 5^2$. We can also rewrite$n^2=9^2=81= 2*4*5 +41$ which really doesn't change the fact that $41=4^2 + 5^2$.
One can convince oneself by decomposing any odd square as done above and look at the final result. $81=9^2= 16 + 2*20 +25$. $20$ is already twice the triangular number $T_{4}=10$. So $81$ is a square that definitely can be written as the sum of 4 times a triangular number and two consecutive squares. One needs only look at the multiplication table to see that $4^2+2*4*5+5^2 = 16 +20 + 20 +25$ add up to $81$.
The diagonals under and above the main diagonal that gives the squares give $2T_{k}$ but since we are adding $2T_{k} +2T_{k}$, we can claim that the odd square we considered is not the sum of a square and twice a triangular number.
So we can write $n^2=9^2=81$ as:
$81= 4^2 + 2*20 + 5^2$ or
$81= 41 + 4*10$
Even squares cannot be decomposed as done above.
