# Find every pair of integers $(p,q)$ such that $\frac {p^3 -q}{pq+1}$ is an integer

Find every pair of integers $(p,q)$ such that $\dfrac {p^3 -q}{pq+1}$ is an integer.

I have tried few pairs, and came with few answers. But I couldn't come with proper solution.

• What are the solutions that you found? – TZakrevskiy Aug 22 '16 at 8:32
• The two statements (title & body) you've given are different. Which one is correct? – Matt Aug 22 '16 at 8:32
• I corrected it. Thanks. – Tahir Imanov Aug 22 '16 at 8:33
• @TZakrevskiy $(q^3 ,q)$ as an example. – Tahir Imanov Aug 22 '16 at 8:35
• $$\dfrac{q(p^3-q)}{pq+1}=p^2-\dfrac{p^2+q^2}{pq+1}$$ See math.stackexchange.com/questions/28438/… – lab bhattacharjee Aug 22 '16 at 8:37

Take any integer $n$. Consider a linear recurrent sequence: $$a_0=0$$ $$a_1=n$$ $$a_{i+1}=n^2\cdot a_i-a_{i-1}$$ The first few sequences are: $$\{0,2,8,30,112,418,1560,5822,21728\dots\}$$ $$\{0,3,27,240,2133,18957,168480,1497363\dots\}$$ $$\{0,4,64,1020,16256,259076,4128960\dots\}$$ Then any pair of subsequent terms (in any order) is a solution. Note also that if we take $(a_i,a_{i+1})$ as our $(p,q)$, the integer they produce is $a_{i-1}$, and if we consider $(p,q)=(a_{i+1},a_i)$ instead, we get $a_{i+2}$.

I'm not sure whether this covers all solutions, though. But I strongly suspect it does.

• You could start with $a_0=0$ to make it simpler and to include the trivial solution p=0. – Jaap Scherphuis Aug 22 '16 at 9:35
• Yeah, you are right. – Ivan Neretin Aug 22 '16 at 9:36

Let $p,q,r\in \mathbb{Z}$

$$\frac{p^3-q}{pq+1}=r \iff \frac{p^3-r}{pr+1}=q$$

Note that $q$ and $r$ are symmetric in roles,

take $q=a_{k+1}$, $r=a_{k-1}$ with $p=a_{k} \,$,

$$a_{k+1}=\frac{a_{k}^3-a_{k-1}}{a_{k} a_{k-1}+1} \iff a_{k-1}=\frac{a_{k}^3-a_{k+1}}{a_{k} a_{k+1}+1}$$

Take $a_{0}=0$ and $a_{1}=n$, that reproduces what Ivan Neretin found.

In particular, for $n=1$, $$a_{k}=\frac{2}{\sqrt{3}} \sin \frac{\pi k}{3}$$

And for $n>1$, $$a_{k}=\frac{n}{\sqrt{n^4-4}} \left[ \left( \frac{n^2+\sqrt{n^4-4}}{2} \right)^k- \left( \frac{n^2-\sqrt{n^4-4}}{2} \right)^k \right]$$