Perfect Square With Two Integer Variables I am trying to solve a number theory problem in general form. However, I got stuck in the following step:
$a,b,n \in \mathbb Z^{+}$ for which values of $n$, this equation is solvable $\frac{(n+1)(n+2a)}{2} = b^2$ ?
Can we make a general statement about $n$ ? By the way I have tried to apply some inequalities with cases $n>a$, $n<a$ and $n=a$ . Also I think modular arithmetic doesn't work so good for this problem.
 A: Clearing denominators and expanding, the question is to find all $n\in\Bbb{Z}$ for which there exist $a,b\in\Bbb{Z}$ such that
$$2b^2=(n+1)(n+2a).$$
So let $n\in\Bbb{Z}$ be given and suppose $a,b\in\Bbb{Z}$ satisfy the above.
Clearly $2b^2$ is divisible by $n+1$, say
$$2b^2=m(n+1),$$
for some $m\in\Bbb{Z}$. It follows that
$$2a=\frac{2b^2}{n+1}-n=m-n,$$
where in particular $m\equiv n\pmod{2}$. With this in mind, let's see for which $n\in\Bbb{Z}$ we can find appropriate $a,b\in\Bbb{Z}$.

*

*If $n$ is even, say $n=2k$, we can take $b=n+1$ to get
$$2b^2=2(n+1)^2,$$
corresponding to $m=2(n+1)$, and correspondingly $a=\frac{m-n}{2}=k+1$, to get
$$\frac{(n+1)(n+2a)}{2}=\frac{(2k+1)(2k+2k+2)}{2}=(2k+1)^2=(n+1)^2=b^2.$$


*If $n$ is odd then $n+1$ is even, so $n+1=2^ck$ for some $c,k\in\Bbb{Z}$ with $c\geq1$ and $k$ odd. If $c$ is odd, say $c=2d+1$, then we may take $b=2^dk$ to get
$$2b^2=2(2^dk)^2=2^{2d+1}k^2=2^ck^2=k(n+1),$$
corresponding to $m=k$, and correspondingly $a=\frac{m-n}{2}=\frac{k+1}{2}-2^{2d}k$, to get
$$\frac{(n+1)(n+2a)}{2}=\frac{2^ck\cdot k}{2}=(2^dk)^2=b^2.$$


*Finally, if $n$ is odd and $n+1=2^ck$ with $c$ is even, say $c=2d$, then
$$2b^2=m(n+1)=2^cmk=(2^d)^2mk,$$
which shows that $m$ is divisible by $2$, i.e. $m\equiv0\pmod{2}$. But this contradicts $m\equiv n\pmod{2}$. So for $n$ of the form $n=4^dk-1$ with $k$ odd and $d\geq1$ there are no such $a$ and $b$.
A: $\frac{1}{2}(n+1)(n+2a) = b^2$
$(2n+1+2a)^2-8b^2 = (2a-1)^2$
Let $x = \frac{\large{2n+1+2a}}{\large{2a-1}}, y = \frac{\large{2b}}{\large{2a-1}}$ then we get
$x^2-2y^2 = 1\tag{1}$
This equation is Pell equation.
The fundamental solution of equation $(1)$ is $(x,y)=(3,2).$
Thus, all of the solutions are given by $x+\sqrt{2}y=\pm(3+2\sqrt{2})^k.$
Hence n and b are given as follows.
$n = (a-\frac{1}{2})x-\frac{1}{2}-a$
$b = \frac{1}{2}y(2a-1)$
For example, some $(x,y)$ is given below.
$(k,x,y)$
$(2,17,12)$
$(3,99,70)$
$(4,577,408)$
$(5,3363,2378)$
$k=2$: take $x=17$ and $y=12$ then we get $(n,b)=(-9+16a, 12a-6).$
