# 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.

• @WillJagy: Confused by your comment…? Maybe my question is unclear. $16$ is a square which can be written as a square and twice a triangular number (as I showed). – Kieren MacMillan Dec 21 '13 at 2:42
• Kieren, alright. – Will Jagy Dec 21 '13 at 2:45

## 2 Answers

$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.

• Thanks! That's great. Do you know if there's any proof in the "downward" direction, i.e. $4n^2+1$ is prime iff and only if $n$ is __________. – Kieren MacMillan Dec 21 '13 at 3:42
• @KierenMacMillan, I would not expect anything general. It is true that all prime factors $p$ of $4 n^2 + 1$ satisfy $p \equiv 1 \pmod 4.$ It is easy enough to tell when $4n^2 + 1$ is divisible by a particular prime such as 5, for instance. – Will Jagy Dec 21 '13 at 3:49
• $4n^2+1$ is prime if and only if $2n+i$ is prime in $\mathbb Z[i]$, which means there is no integer solution to $ux+vy=2n$ and $uy-vx=1$ for $u,v,w,z$ all non-zero. Don't think there is any better characterization for such $n$ - I wonder even if it is known that there are infinitely many $n$ such that $4n^2+1$ is prime. – Thomas Andrews Dec 21 '13 at 3:50
• @ThomasAndrews not known. – Will Jagy Dec 21 '13 at 3:50
• @WillJagy I'd include a comment before you snapshots to indicate what the purpose of the included images are. – Thomas Andrews Dec 21 '13 at 3:52

$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.