Find $a \in \mathbb N$ such that $x^2+ax-1 = y^2$ has a solution in positive integers Question: Find all the positive integers $a$ such that $x^2+ax-1 = y^2$ has a solution in positive integers $(x,y)$.
Comments: It's easy to see that this equation rarely has a solution (in the sense that for a fixed $a$, $x^2+ax-1$ is a perfect square only for finitely many values of $x$). In fact, if $a$ is even then $x^2 \le x^2+ax-1 < (x+a/2)^2$, so $x^2+ax-1$ is almost never a perfect square. The problem is that I can't control the interval $[x^2,(x+a/2)^2)$ when $a$ grows. There's a similar argument for $a$ odd.
However, it is possible to find some families of such $a$'s. For instance, if $a$ is a perfect square, say $a=k^2$, then there exists the solution $(x,y) = (1,k)$.
In addition, if $x > 1$ then its prime power factors are $2$ and/or $p^\alpha$, where $p \equiv 1 \pmod 4$. In fact, if $p|x$ then the constraint of the equation modulo $p$ yields that $-1$ is a square.
 A: $x^2+ax-1 = y^2 \implies (2 x + a)^2 - (2 y)^2 = 4 + a^2$
gp-code:
axy()=
{
 for(a=1, 100,
  S= [];
  T= thue('x^2-1, 4+a^2);
  for(i=1, #T,
   x= (T[i][1]-a)/2;
   y= T[i][2]/2;
   if(x>0 & y>0,
    if(x==floor(x) & y==floor(y),
     S= concat(S, [[x,y]]);
    )
   )
  );
  if(#S, print1(a", "))
 )
};

Output:
1, 3, 4, 5, 7, 8, 9, 11, 12, 13, 15, 16, 17, 19, 20, 21, 23, 24, 25, 27, 28, 29, 31, 32, 33, 35, 36, 37, 39, 40, 41, 43, 44, 45, 47, 48, 49, 51, 52, 53, 55, 56, 57, 59, 60, 61, 63, 64, 65, 67, 68, 69, 71, 72, 73, 75, 76, 77, 79, 80, 81, 83, 84, 85, 87, 88, 89, 91, 92, 93, 95, 96, 97, 99, 100,

I.e. $a\not\equiv 2\pmod{4}$
A: Actually, every $a$ that is not $2 \pmod 4$ yields a solution.  These $a$ are impossible because then
$$x^2 + ax - 1 \equiv x^2 + 2x - 1 \equiv (x - 1)^2 - 2 \pmod 4,$$
which is either $2$ or $3$ mod $4$, but squares are only $0$ or $1$ mod $4$.
For the other $a$, I will construct values of $x$ that work.
For $a = 4k$, take $x = 2k^2 - 2k + 1 = \frac{(2k - 1)^2 + 1}{2}$.  Then
\begin{align*}
x^2 + ax - 1 &= (2k^2 - 2k + 1)^2 + 4k(2k^2 - 2k + 1) - 1\\
             &= (4k^4 - 8k^3 + 8k^3 - 4k + 1) + (8k^3 - 8k^2 + 4k) - 1\\
             &= 4k^4\\
             &= (2k^2)^2
\end{align*}
For $a = 4k + 1$, take $x = 4k^2 + 1$.  Then
\begin{align*}
x^2 + ax - 1 &= (4k^2 + 1)^2 + (4k + 1)(4k^2 + 1) - 1\\
             &= (16k^4 + 8k^2 + 1) + (16k^3 + 4k^2 + 4k + 1) - 1\\
             &= 16k^4 + 16k^3 + 12k^2 + 4k + 1\\
             &= (4k^2 + 2k + 1)^2
\end{align*}
For $a = 4k + 3$, take $x = 4k^2 + 4k + 2$.  Then
\begin{align*}
x^2 + ax - 1 &= (4k^2 + 4k + 2)^2 + (4k + 3)(4k^2 + 4k + 2) - 1\\
             &= (16k^4 + 32k^3 + 32k^2 + 16k + 4) + (16k^3 + 28k^2 + 20k + 6) - 1\\
             &= 16k^4 + 48k^3 + 60k^2 + 36k + 9\\
             &= (4k^2 + 6k + 3)^2
\end{align*}
