Given any equation of form $x^2-ny^2 = 1$, where $n$ is positive, non-square integer, let $[a_0; \overline{a_1, a_2, \dots a_k}]$ denote the continued fraction $\sqrt{n}$.
Let $\frac{p_i}{q_i} = [a_0; a_1, a_2, \dots a_{(k-1)i}]$. Why is it true that the solution of the Pell's equation exists in $\left\{\frac{p_1}{q_1}, \frac{p_2}{q_2}, \dots\right\}$.
More specifically, why doesn't a solution exist outside the set?
By a solution, I mean $p_i^2 - nq_i^2=1$.