Find the value of an integer $a$ such that $ a^2 +6a +1 $ is a perfect square. I was able to solve this but it required me using hit and trial at one step. I was wondering if i could find a more solid method to solve it.
p.s. this is the first time im asking a question here so sorry if i couldn't construct the question properly.
this is my solution -
$a^2 + 6a + 1 = k^2$
$(a+3)^2 = k^2 + 8$
$k^2 + 8 = m^2 $    where [$m=a+3$]
$(m-k)(m+k) = 8$ ... here by inspection $m= 3$ and $k =1$
hence, $a = 0, -6$.

hint
$$a^2+6a+1=b^2$$
$$\iff a^2+6a+1-b^2=0$$
the reduced  discriminant is
$$\Delta'=9-1+b^2=b^2+8$$
$$a=-3\pm \sqrt{b^2+8}$$
thus
$$b^2+8=c^2$$
and
$$(c+b)(c-b)=8$$
$$=4×2=-4×(-2)$$
$$c+b=\pm 4,\;\; c-b=\pm 2$$
gives $$\;\; b=\pm 1$$
and in all cases,
$$a=0 \text{ or } a=-6$$
