I'm trying to find the smallest integer solution to
$$n^2 = 2d^2 - 2d + 1$$
Additional constraints: $$d > 10^{12}, n > 0$$
I wrote a computer program to bruteforce it, but that is too slow.
This page says that I can consider the equation modulo some prime to find whether it has solutions, but I already know that it has a solution, I just don't know what it is.
It's $$n^2=d^2+(d-1)^2$$ and we got Pythagorean triples because we can assume that $d-1>0$,
otherwise it's or obvious or the same.
Since $gcd(d,d-1)=1$, we have two cases.
$d=2mn$ and $d-1=m^2-n^2$, where $gcd(m,n)=1$, $m>n$ and $mn$ is even;
$d=m^2-n^2$ and $d-1=2mn$.
We got two Pell's equations: $$(m+n)^2=1+2m^2$$ and $$(m-n)^2=1+2n^2.$$ They are $y^2=1+2x^2$ with a minimal solution $(2,3)$ and from here we can get all solutions.