I ask this question based on a comment of David Speyer in another question. What primes are of the form $$ \frac{p^2-1}{q^2-1} $$ where $p$ and $q$ are prime?

The first prime not apparently of this form is 17. The Diophantine equation $$ p^2-17q^2+16=0 $$ has solutions following a linear recurrence relation which has no primes in the first 1000 terms (only $(\pm1, 1)$ seeds may contain primes). But perhaps there is a better way to go about this?


Solution 1:

I think for the equation:

$$\frac{x^2-1}{y^2-1}=k$$

It is necessary to record decisions. We will use the solutions of the Pell equation.

$$p^2-ks^2=1$$

And then the solutions are of the form:

$$x=-p^2+2kps-ks^2$$

$$y=p^2-2ps+ks^2$$