Find the first non-prime Find the first non-prime $x(d)$ in Pell’s equation using the procedure below.
For every prime number $p$, construct a (possibly empty) series of natural numbers using the following procedure (start with $p=2$): Solve Pell’s equation 
$$xx-dyy=1 \qquad \text{for } d=p-1$$ 
We note that $x$ (and $y$) depend on $d$ and rewrite the equation
$$
(x(d))^2 – d (y(d))^2=1
$$ for clarity.
If $p-1$ is a square (as it is for $p=2$) and consequently the equations will not have a solution, continue to the next higher prime $p=3$. 
Solve Pell-s equation for $d= p-1=2$ and find the solution $x(2)=3$. Now continue to solve the equation for a new constant 
$d_2=x(d-1)-1=2$. 
In this case the equation 
$$(x(2))^2-2(y(2))^2=1$$
has the solution $x(2)=3$. This presents us with the second reason to stop the process, circularity in the occurrence of numbers, since $2=d3=d2$.
Continue to the next prime $p=5$ (and dismiss it on the ground that $p-1$ is a square).
Note that our solution for $x$, $x(2)=3$ has been a prime. The problem is to find the first non-prime $x$ following this procedure.
 A: If I understood the procedure correctly, it seems that the process looks as follows:


*

*$2$ (square plus 1)

*$3\Rightarrow 3$ (repetition)

*$5$ (square plus 1)

*$7\Rightarrow 5$ (repetition)

*$11\Rightarrow 19\Rightarrow 17$ (square plus 1)


(here I'm not sure if you want to go to next prime after $17$ or to the smallest not-yet-tried prime; it doesn't matter much in this case anyway)


*

*$13\Rightarrow 7$ (repetition)

*$17$ and $19$ (repetition)

*$23\Rightarrow 197$ (square plus 1)


(the same dilemma here... but in this case, it matters)


*

*$29\Rightarrow 127\Rightarrow 449\Rightarrow 127$ (repetition)

*$31\Rightarrow 11$ (repetition)

*$37$ (square plus 1)

*$41\Rightarrow 19$ (repetition)

*$43\Rightarrow 13$ (repetition)

*$47\Rightarrow 24335$ (composite at last!)


If, instead of proceeding to $29$, you intended to go to the prime following $197$, it'd look like this:


*

*$199\Rightarrow 197$ (repetition)

*$211\Rightarrow 29\Rightarrow 127\Rightarrow 449\Rightarrow 127$ (repetition)

*$131\Rightarrow 6499$ (composite!)

