<s>[INST] 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.
 [/INST] $\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).$
</s>