<s>[INST] $p^2+1=q^2+r^2$. Strange phenomenon of primes Problem:
Find prime solutions to the equation
$p^2+1=q^2+r^2$
I welcome you to post your own solutions as well
I have found a strange solution which I can't understand why it works(or what's the math behind it.) Here it is through examples
Put $r=17$(prime)
Now $17^2-1=16\times 18=288=2 \times 144$ (a particular factorization)
$\frac {2+144}{2}=73$
$\frac {144-2}{2}=71$
Solution pair $(p,q,r)=(73,71,17)$
Put $r=23$, 
$23^2-1=22\times 24=8\times 66$
$\frac {8+66}{2}=37$
$\frac {66-8}{2}=29$
Solution pair $(37,29,23)$
It works for each prime except for $2,3,5$ Which generate 
$(2,2,1),(3,3,1),5,5,1)$
Please explain me how it's working 
 [/INST] This seems to hold much more broadly than just for primes.
Let$$r^2-1=ab$$where $b>a$, and let $p=\frac{b+a}{2}$ and $q=\frac{b-a}{2}$.
Then the equation $p^2+1=q^2+r^2$ becomes$$\left(\frac{b+a}{2}\right)^2+1=\left(\frac{b-a}{2}\right)^2+ab+1$$and we have$$\frac{b^2+2ab+a^2}{4}+1=\frac{b^2-2ab+a^2+4ab}{4}+1=\frac{b^2+2ab+a^2}{4}+1$$
Addendum: If $r$ is an odd prime, then $p$ and $q$, that is $\frac{b+a}{2}$ and $\frac{b-a}{2}$, can be prime only if both are odd, i.e. only if $b\equiv 2\pmod 4$ and $a\equiv 0\pmod 4$, or vice-versa.
This restricts the number of divisor pairs $a, b$ that need to be considered in determining whether $r^2-1=ab$ for some odd primes $p$ and $q$.
To illustrate, let $r=47$. Then$$r^2-1=ab=2208=2^5\cdot3\cdot23$$Thus the possible $ab$ are $2\cdot 1104$, $6\cdot 368$, and $2^4\cdot 138$.
For $b=1104$, $a=2$, $p=\frac{b+a}{2}=553=7\cdot79$, not prime.
For $b=368$, $a=6$, $p=\frac{b+a}{2}=187=11\cdot17$, not prime.
For $b=138$, $a=2^4$, $p=\frac{b+a}{2}=77=7\cdot11$, not prime.
It seems $47$ is the least prime value of $r>3$ for which$$p^2+1=q^2+r^2$$is true for no primes $p$, $q$.
As @Gerry Myerson shows, $r=193$ is another instance. I've yet to find  other primes between these two, but have not looked much beyond $r=97$.
</s>