I want to find all integer solutions for m and n such that $p=\frac{n^2-1}{m^2}$, where p is a prime number
as an example, I plugged in p=3 in wolfram and I got that the following values of m and n would work
$m=\pm \frac{(2-\sqrt3)^k-(2+\sqrt3)^k}{2 \sqrt3}$
$n=\pm \frac{1}{2} (-(2-\sqrt3)^k-(2+\sqrt3)^k), k\in Z, k\ge1$
but, how does wolfram get this? how could I do it for a given prime p other than 3?