<s>[INST] Find all primes $p$ for which there are positive integers $x, y$ such that $p+1=2x^2$ and $p^2+1=2y^2$ Find all primes $p$ for which there exist positive integers $x, y$ such that $p+1=2x^2$ and $p^2+1=2y^2$.
I have tried coming up with an equation for $p$ or $p^2$ and this is what I've got
$p=2x^2-1$;
$p^2=(2x^2-1)^2$
$p^2=2y^2-1$
which means $(2x^2-1)^2=2y^2-1$ but this doesn't do much...
 [/INST] So $$p(p-1)=p^2-p=2y^2-2x^2=2(y+x)(y-x)$$
One of the three factors on the right must be $p$ or a multiple thereof, and it must be the largest among the three. We conclude $p\mid x+y$. But clearly $x<p$ and $y<p$, hence we can only have $p=x+y$. Then $p-1=2(y-x)$, hence $y=3x-1$.
Now by simple algebraic manipulations,$$(2x^2-1)^2=p^2=2(3x-1)^2-1 $$
$$4x^4-4x^2+1=18x^2-12x+1 $$
$$4x^4-22x^2+12x=0 $$
$$x(x-2)(x^2+x-\tfrac32)=0 $$
showing that $x=2$ is the only possible positive integer, and it leads to $y=5$ and the only solution $$p=7.$$
</s>