<s>[INST] Numbers of the form $8k^2-1$ in a sequence defined by $a_0=-1$, $a_1=1$ and $a_{n+2}=6a_{n+1}-a_n$. 
Suppose a sequence $\{a_n\}_{n\in\mathbb{N}}$ is defined by $a_0=-1$, $a_1=1$ and $$a_{n+2}=6a_{n+1}-a_n$$ for all $n\in\mathbb{N}$. Find all $n$ such that $a_n$ is of the form $8k^2-1$ for some $k\in\mathbb{N}$.

The problem comes from Bulgaria National Olympiad 2003, Problem 3:

Given the sequence $\{y_n\}_{n\in\mathbb{N}_+}$ defined by $y_1=y_2=1$ and
  $$y_{n+2}=(4k-5)y_{n+1}-y_n+4-2k,\qquad n\in\mathbb{N}_+.$$
  Find all $k\in\mathbb{Z}$ such that $y_n$ is a perfect square for all $n\in\mathbb{N}_+$.

I attempted to solve this problem by using the fact that $y_2=2k-2$ and $y_3=8k^2-20k+3$ are perfect squares. Let $2k-2=(2u)^2$ and $8k^2-20k+3=v^2$, and we have negative Pell's equation $$(8u^2-1)^2-2v^2=-1.$$ The general solution to $x^2-2y^2=-1$ is given by $x_n+y_n\sqrt{2}=(1+\sqrt{2})^{2n+1}$, thus leading to my original question.
Obviously, $a_0=-1$ and $a_2=7$ is of the form $8k^2-1$. How do I prove that these are the only solutions?
 [/INST] Work in progress ...
Proposition 1. $a_{2k} \equiv -1 \pmod{8}$
Proof. Leaving the theoretical material aside, characteristic polynomial of the recurrent sequence is
$$x^2-6x+1=0$$
with the solutions $x_1=3-2\sqrt{2},x_2=3+2\sqrt{2}$, thus
$$a_n=A(3-2\sqrt{2})^n+B(3+2\sqrt{2})^n$$
or, given the initial conditions
$$a_n=\left(-\frac{1}{2}-\frac{1}{\sqrt{2}}\right)(3-2\sqrt{2})^n+\left(-\frac{1}{2}+\frac{1}{\sqrt{2}}\right)(3+2\sqrt{2})^n$$
One thing to mention is that
$$(3-2\sqrt{2})^n=C-D\sqrt{2}\\
(3+2\sqrt{2})^n=C+D\sqrt{2}$$
both $C,D \in \mathbb{Z}$ and
$$a_n=2D-C$$
But
$$C=3^{n}+\binom{n}{2}3^{n-2}(2\sqrt{2})^2+\binom{n}{4}3^{n-4}(2\sqrt{2})^4+...=3^{n}+8Q$$
$$D=\binom{n}{1}3^{n-1}2+\binom{n}{3}3^{n-3}2^3\sqrt{2}^2+\binom{n}{5}3^{n-5}2^5\sqrt{2}^4+...=n3^{n-1}2+8R$$
Thus 
$$a_n+1=2D-C+1=n3^{n-1}4-3^{n}+1+16R-8Q$$
Or if
$$3^{n-1}(4n-3)+1\equiv 0 \pmod{8} \Rightarrow a_n \equiv -1 \pmod{8}$$
which is true only for even $n=2k$, since
$$4n-3=8k-3 \equiv -3 \pmod{8}\Rightarrow 3^{n-1}(4n-3)+1 \equiv -3^{2k}+1 \equiv 0 \pmod{8} \tag*{$\blacksquare$}$$
Note for odd $n=2k+1 \Rightarrow 4n-3=8k+1 \equiv 1 \pmod{8} \Rightarrow$ $3^{n-1}(4n-3)+1 \equiv 3^{2k}+1 \not\equiv  0 \pmod{8}$, since $9 \equiv 1 \pmod{8}$.
</s>