I have a polynomial of the second degree $a\cdot n^2 + b \cdot n + c$ and I need to find out natural numbers $n$, such that $\sqrt{a\cdot n^2 + b \cdot n + c}$ is also a natural number.

After thinking about this problem, my idea was to rewrite it into $a\cdot n^2 + b \cdot n + c = x^2$ and rewrite it to look like a [Pell's equation](https://en.wikipedia.org/wiki/Pell%27s_equation):

$$(2an + b)^2 - 4ax^2= b^2 - 4 ac$$
which kind of resembles $x^2 - n y ^2 = 1$, but not really close enough to for me to solve it.

Then I tried to find some similarities in solutions for particular cases. For example when I took the equation $\sqrt{3\cdot n^2 - 2 \cdot n - 1}$ and wrote the program, the couple of first values were: `1, 5, 65, 901, 12545` (with no visible pattern for me).

---

So how should I solve this problem?