Find all pairs of positive rationals $(a, b)$ with $\frac{ab+1}{a}$, $\frac{ab+1}{b}$ both integers I was just trying to do the following question:
Find all pairs of real rational numbers $(a, b)$ such that the numbers $\frac{ab+1}{a}$, $\frac{ab+1}{b}$ are both integers.
I didn't even know how to start it. I thought of using number theory, however, that's about it. I then looked at the solution and it is as follows:
The numbers $a+\frac{1}{b}$ and $b+\frac{1}{a}$ are integers, hence we have that the number:
$(a+\frac{1}{b})(b+\frac{1}{a})=ab+\frac{1}{ab}+2$ is an integer. Hence we have that the number $ab+\frac{1}{ab}$ is an integer.
I state that $ab=\frac{k}{l}$ where $k$ and $l$ are integers and $(k, l)=1$. We want $\frac{k^2+l^2}{kl}\in Z$. Since $k|kl$ and $kl|k^2+l^2$, $k|l^2$ and since $(k, l)=1$, we have that $k=1$. Similarly we prove that $l=1$. Hence $ab=1$ and $2a$, $2b$ are integers hence the solutions are $(a, b)=(\frac{1}{2}, 2), (1, 1), (2, \frac{1}{2})$.
I have fully understood this solution, however I haven't managed to comprehend how to originally think of going down this path, how to intuitively realize that this is what I am supposed to do. Could you please explain to me how to intuitively think of it and also, if there exists a more intuitive solution-thought pattern could you please post it?
 A: The idea is simple as we want to get a one variable equation to study which happens to be $P=ab$.
From $P+1/P-n=0$ we have the second degree polynomial $P^2-nP+1=0$. Now solving in $P=\dfrac{n\pm\sqrt{n^2-4}}{2}$
Getting back $ab=P$ and $\dfrac{P+1}{P/a}=c\in \mathbb{Z}$ and $\dfrac{P+1}{a}=d\in \mathbb{Z}$
$a=\dfrac{cP}{1+P}$ and $a=\dfrac{P+1}{d}$
so $$cdP=P^2+1+2P$$ since $P^2+1=nP$, taking $cd=n+2$ gives the solutions in $\mathbb{R}$
If you want solutions in $\mathbb{Q}$ then as it is said $n=\pm 2$ and $P=\pm 1$
A: Let $m$ and $n$ be any integers such that either $mn\geqslant4$ or $mn<0$. Then $$a=\tfrac12[m\pm\surd(m^2-4m/n)]\quad\text{and}\quad b=\tfrac12[n\pm\surd(n^2-4n/m)]$$satisfy the condition that $a+1/b$ and $b+1/a$ are integers. This can readily be checked by substituting for $a$ and $b$, eliminating the surd in the denominator, and simplifying.
To show the necessity of the result, let $a+1/b=m$ and $b+1/a=n$. By adding and subtracting these equations, dividing the resulting equations to eliminate the common factor $1+1/ab$, and rearranging, it can easily be found that$$\frac ab=\frac mn.$$Substituting for $b$ (resp. $a$) from this result, we obtain a quadratic equation $na^2+m=mna$ for $a$ (and similarly for $b$) which yields the above solution via the quadratic formula.
If we add the requirement of the new, edited, question, then only solutions for which the surds are rational may be accepted. Thus, in addition, $m^2n^2-4mn$ must be a perfect square. It follows that there is such a square of the form $(mn-2)^2-4$. But the only squares that differ by $4$ are $0$ and $4$. Hence $mn-2=\pm2$, and therefore $mn=4$, since $mn\neq0$. This leaves the only possibilities for $a$ as $\pm\frac12$, $\pm1$, and $\pm2$, with the corresponding value for $b$ as the reciprocal of $a$.
