TITLE: squares which are not the sum of a square and twice a triangular number
QUESTION [6 upvotes]: 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.

REPLY [2 votes]: $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.