If $ab+1 = r^2$ for $a,b,r \in \mathbb{N},$ how to show that $\gcd(2a(r+b)+1,2b(r+a)+1) = 1?$ Let $a<b$ be positive integers such that $ab+1 = r^2$ for some $r \in \mathbb{N}.$ If $m_1 = 2a(r+b)+1$ and $m_2 = 2b(r+a)+1.$ I want to find the possible values of $\gcd(m_1,m_2).$ I had taken some examples in the range $a,b\in\{1,2,\dots 1000\},$ and found the corresponding values as $\gcd(m_1,m_2) = 1.$ Is $\gcd(m_1,m_2) = 1$? If yes, how to prove it? If no, provide a counter example.Only thing that I could see is $\gcd(a,r)=\gcd(b,r) = 1.$
 A: $\!\!\!\begin{align}
\bmod \:\!d\!=\!{\rm gcd}\!:\ &{-}2\color{darkorange}a(\color{#4bf}{r\!+\!b})\equiv 1 \equiv 2\:\!\color{#0a0}r\:\!(r\!+\!a),\, \ {\rm by}\ \ \color{darkorange}a\color{#4bf}b\equiv r^2\!-1\:\ \small\text{(cf. comments)}\\[.2em]
{\rm thus}\ \ \ \  &{-}2\color{#c00}b(r\!+\!a)\equiv 1\:\!\Rightarrow\, \smash{\overset{\overset{\color{#0a0}{\Large\updownarrow}}{\phantom{"}}}{\color{#0a0}r}}\equiv \frac{1}{2(r\!+\!a)}\equiv-\color{#c00}b\Rightarrow \color{#4bf}{r\!+\!b}\equiv 0\Rightarrow 0\equiv 1\Rightarrow\:\! \bbox[4px,border:1px solid #c00]{d\mid 1}\end{align}$
A: We are given that $ab+1=r^{2}$.
Note
$$2a(r+b)+1 = 2ar + 2ab+1 = 2ar+2r^2-1$$
$$2b(r+a)+1= 2br+2r^2-1$$
We claim that the gcd of the above two quantities is $1$.
$\textbf{For proof by contradiction}$ suppose that there is some prime $p$ that divides both $2ar+2r^2-1$ and $2br+2r^2-1$. Then note that $ p \not \div 2r, p \not \div a, p \not \div b$.
If $p \div 2r^2-1$, then $p|a$ and $p|b$, but $(ab, 2r^2-1) = (r^2-1,2(r^2-1)+1) = 1$ $\Rightarrow$ Thus $p \not \div 2r^2-1$
From $2ar+2r^2-1 \equiv 0 \mod p$ we get $a \equiv (1-2r^2)(2r)^{-1}\mod p $
From $ab = r^2 -1$ we get $b \equiv (r^2-1)(a)^{-1} \equiv (2r^3-2r)(1-2r^2)^{-1} \mod p$
Note that we also have $a \equiv b \mod p$ as $2ar+2r^2-1 \equiv 2br+2r^2-1 \mod p$. Thus
$$(1-2r^2)(2r)^{-1} \equiv (2r^3-2r)(1-2r^2)^{-1} \mod p$$
$$ \Rightarrow (1-2r^2)^2 \equiv 4r^4-4r^2 \mod p$$
$$\Rightarrow 1 \equiv 0 \mod p$$
Which is impossible.
A: If there is a prime $p$ such that $p$ divides both then clearly $p\ne2$ and divides their difference $$p\mid 2r(a-b)$$
So we have 2 possibilities:

*

*If $p\mid r$ then $p\mid 2ab+1$ and $p\mid ab+1$ so $p\mid 2(ab+1)-(2ab+1)=1$. A contradiction.


*If $p\mid a-b$ then we get $p\mid 2ar+2a^2+1$. But $p\mid a^2+1-r^2$ so $p\mid a^2+2ar+r^2$ and thus $p\mid a+r$ and now also $p\mid 2b(a+r)$. But then $p\mid 1$. A contradiction.
So there is no such $p$ and thus a conclusion.
