# Can sum of a rational number and its reciprocal be an integer?

Can sum of a rational number and its reciprocal be an integer?

My brother asked me this question and I was unable to answer it.

The only trivial solutions which I could think of are $1$ and $-1$.

As to what I tried, I am afraid not much. I have never tried to solve such a question, and if someone could point me in the right direction, maybe I could complete it on my own.

Please don't misunderstand my question.

I am looking for a rational number $r$ where $r + \frac{1}{r}$ is an integer.

• Think about rationals of the form $1/q$ for non-zero integer q. – Jihoon Kang Aug 19 '17 at 15:40
• @ThomasAndrews No, I mean rationals. – Agile_Eagle Aug 19 '17 at 15:47
• Yeah, the original language was the confusion. – Thomas Andrews Aug 19 '17 at 15:49
• @ThomasAndrews My bad! But I hope it is clearer now. – Agile_Eagle Aug 19 '17 at 15:50

Let $\frac{m}{n}+\frac{n}{m}=k$, where $\gcd(m,n)=1$ and $\{m,n,k\}\subset \mathbb N$.

Thus, $m^2+n^2=kmn$, which gives that $m^2$ divisible by $n$ and $n^2$ divisible by $m$.

Try to end it now.

• Why is it necessary to claim $\gcd(m,n)$? Why can’t you ignore that line - $m^2+n^2=kmn$ is valid either way, given that $\{m,n,k\}\subset \mathbb N$? Further, when you say “try to end it now,” are you insinuating that it is impossible for $n$ to divide $m^2$ and vice versa if $\gcd(m,n)=1$? – DonielF Aug 20 '17 at 12:14
• @ DonielF Because it's more convincing. Now for all prime $p$ for which $n$ divisible by $p$ we see that also $m$ divisible by $p$, which is contradiction. – Michael Rozenberg Aug 20 '17 at 15:09
• @DonielF Assuming $gcd(m,n)=1$ shortens the proof, because a solution for any other case $(km,kn)$ implies there's a solution for $(m,n)$. So, If there isn't a solution when $gcd(m,n)=1$, there isn't a solution for any $(km,kn)$. Finally, Michael was trying to leave you something to figure out for yourself. – Spencer Aug 20 '17 at 16:55
• @DonielF This hinted proof is precisely equivalent to the usual proof of RRT = Rational Root Test for the special quadratic $\, \color{#c00}1x^2 - k\,x + \color{#0a0}1\,$ with root $\,x = m/n\,$ in least terms. RRT $\Rightarrow n\mid\color{#c00}1,m\mid\color{#0a0}1.\,$ But RRT generally fails if the root $\,x = m/n\,$ is not expressed in least terms, i.e. when $\,\gcd(m,n)>1.\,$ For example $\,\color{#0a0}2/\color{#c00}6\,$ is a root of $\,\color{#c00}3x-\color{#0a0}1\,$ but $\,\color{#c00}{6\nmid 3},\ \color{#0a0}{2\nmid 1}\$ (continued below) – Bill Dubuque Aug 21 '17 at 0:23
• If RRT is known it is clearer to simply invoke it rather than repeat its proof for this special polynomial. In fact the RRT viewpoint easily leads to more general results, e.g. see my answer. – Bill Dubuque Aug 21 '17 at 0:23

It seems like you are asking for a rational number $n$ with the property that $$n+\frac{1}{n}$$ is an integer. Let $z$ be an integer. Then we have $$n+\frac{1}{n}=z$$ and $$n^2+1=zn$$ $$n^2-zn+1=0$$ and by the quadratic formula, $$n=\frac{z\pm\sqrt{z^2-4}}{2}$$ And so $z$ must be an integer, and $z^2-4$ must be a perfect square. This can only happen when $z=\pm2$, so we have $$n=\frac{\pm2\pm\sqrt{2^2-4}}{2}$$ $$n=\frac{\pm2}{2}$$ $$n=\pm 1$$ Looks like you've found the only solutions!

• +1 though I would have preferred $r$ (or even $z$) to represent the rational and $n$ for the integer – Henry Aug 19 '17 at 15:52
• How did you know that “This can only happen when $z=\pm2$…”? – Chase Ryan Taylor Aug 19 '17 at 17:27
• @ChaseRyanTaylor The difference between the $n$th perfect integer square and the $n+1$th perfect integer square is $2n-1$ (if you count $0$ as the first). – Frpzzd Aug 19 '17 at 17:29
• @ChaseRyanTaylor $z^2-4$ is a perfect square, therefore there exists some integer $s: z^2-4=s^2$, hence $z^2-s^2=4$, $(z+s)(z-s)=4$, and thus $z+s = z-s = \pm 2$ – PM 2Ring Aug 19 '17 at 19:01
• The argument is incomplete since you don't justify the claim $\,z^2-4 = k^2\,\Rightarrow\, k = 0.\,$ It's much simpler to apply the Rational Root test to $\ n^2 - z\, n + 1 \$ to deduce that the only possible rational roots are $\,\pm 1.\,$ For more on that viewpoint see my answer. – Bill Dubuque Aug 19 '17 at 22:07

Generally if $$\ r\in \Bbb Q,\,c\in\Bbb Z\$$ then $$\ \overbrace{r + c/r}^{\large\ b}\in\Bbb Z \iff r,\, c/r \in \Bbb Z\,\$$ [OP is case $$\,c = 1\,\Rightarrow\, r=\pm1 ]$$

Proof $$\ (\Rightarrow)\,\ \ r^2 - b\, r + c = 0\,\Rightarrow\,r\in \Bbb Z,\,$$ $$\,r\mid c\,$$ by  RRT = Rational Root Test. $$\,\ (\Leftarrow)\$$ Clear.

Remark  More generally if $$\ a\, r + c/r = b\$$ for $$\,a,b,c\in\Bbb Z\,$$ then scaling by $$\,a\,$$ as above we deduce $$\ a\,r^2 - b\,r + c = 0\,$$ so RRT $$\Rightarrow\, r = e/d,\ \gcd(e,d)=1,\ e\mid c,\ d\mid a.\,$$ If $$\,a,c\,$$ have $$\rm\color{#c00}{few}$$ factors then only a $$\rm\color{#c00}{few}$$ possibilities exist for $$\,r,\,$$ e.g. if $$\,a,c\,$$ are primes then $$\,\pm r = 1,\, c,\,1/a,\,$$ or $$\,c/a\,$$.

These are special cases of ideas going back to Kronecker, Schubert and others which relate the possible factorizations of a polynomial to the factorizations of its values. In fact we can devise a simple (but inefficient) polynomial factorization algorithm using these ideas. For more on this viewpoint see this answer and its links.

Suppose $\frac pq+\frac qp =n$ then $p^2+q^2=pqn$ for integers $p,q,n$. As a quadratic in $p$ this is $p^2-qnp+q^2=0$ so that $$p=\frac {qn\pm \sqrt {q^2n^2-4q^2}}{2}$$ so that for the square root to yield an integer we require $n^2-4=m^2$ for some integer $m$. The only two integer squares which differ by $4$ are $0$ and $4$, so $n=\pm 2$ and the only solutions are $p=\pm q$.

This is equivalent to the quadratic formula solutions, but I like it a little better.

Suppose that $r=\frac{a}{b}$, and $r+\frac{1}{r}=\frac{a}{b} + \frac{b}{a} = k$ is an integer. We can rewrite this equation as $a^2 + b^2 = kab$, and multiplying by $4$ completing the square gives us: $$(2a-kb)^2 = (k^2 - 4)b^2$$

For this equation to hold, $k^2 - 4$ must be a square. The squares are $0,1,4,9,\ldots$ with growing consecutive differences, so this is only possible if $k^2=4$, or $k=\pm 2$.

Finally, this gives us $(2a-kb)^2 = 0$, or $a=\pm b$. In other words, $r=\pm 1$.

Let $r = \frac mn$

so $r + \frac 1r = \frac mn + \frac nm = \frac {m^2 + n^2}{mn}$

Let $p$ be prime so that $p|m$ but $p\not \mid n$. Then $p\not \mid m^2 + n^2$ and $r + \frac 1r$ is not an integer. The same would apply for any $q$ prime that divides $n$ but not $m$.

So for $r + \frac 1r$ to be an integer $m$ and $n$ must have the same prime factors.

But we express $r = \frac mn$ "in lowest terms", then $m$ and $n$ have no prime factors in common. So $m$ and $n$ can not have any prime factors! There are only two numbers that do not have any prime factors. Those are $\pm 1$.

So $r = \frac {\pm 1}{\pm 1} = 1, -1$. The two trivial answers. Those are the only answers.

Lemma(1): Let $a$ & $b$ be integers such that $ab \mid a^2+b^2$. If $\gcd(a,b)=1$, then prove that $a=\pm b$.

Proof: We claim that $ab=\pm 1$.

• Proof of the claim: Suppose on contrary; that $1 < |ab|$. So there exist a prime number $p$, which divides $ab$; i.e. $p \mid ab$. Without loss of generality we can assume that $p \mid a$. So $p$ must divides $b^2=(a^2+b^2)-a^2$. [Because $p$ divides both of the $(a^2+b^2)$ & $a^2$.] So we can conclude that $p$ must divides $b$; which is an obvious contradiction with the assumption that $\gcd(a,b)=1$.

So we can conclude that $a=\pm 1$ & $b=\pm 1$; which implies that $a=\pm b$.

Lemma(2): Let $a$ & $b$ be integer such that $ab \mid a^2+b^2$. Prove that $a=\pm b$.

Proof: Let $d:=\gcd(a,b)$, so there exist integers $a^{\prime}$ & $b^{\prime}$ such that:

$$a=da^{\prime} \ , \ \ \ \ \ \ \ b=db^{\prime} \ , \ \ \ \ \ \ \ \gcd(a^{\prime},b^{\prime})=1 .$$

The relation $ab \mid a^2+b^2$, implies that there is an integer $k$, such that:

$$k(ab) = a^2+b^2 \Longrightarrow k\big( (da^{\prime})(db^{\prime}) \big) = (da^{\prime})^2+(db^{\prime})^2 \Longrightarrow k\big( a^{\prime}b^{\prime} \big) = (a^{\prime})^2+(b^{\prime})^2 ,$$

so we obtain a pair $(a^{\prime},b^{\prime})$ such that:

$$a^{\prime}b^{\prime} \mid (a^{\prime})^2+(b^{\prime})^2 \ , \ \ \ \ \ \ \ \ \ \ \ \ \gcd(a^{\prime},b^{\prime})=1 .$$

So by Lemma(1) we have:

$$a=d(a^{\prime})=d(\pm b^{\prime})=\pm d(b^{\prime})=\pm b .$$

Let $\dfrac{r}{s}$ be an arbitrary non-zero rational number, i.e. $r,s \neq 0$.

Suppose that $\dfrac{r}{s}+\dfrac{s}{r}=n$ for some integer $n$.
Then we have: $\dfrac{r^2+s^2}{rs}=n$;
which implies $rs \mid r^2+s^2$;
so we can conclude that $r=\pm s$.

• “Suppose on the contrary; that $1<|ab|$.” That’s not the only alternative hypothesis; why can’t $1>|ab|$? Maybe $a$ and $b$ are both 0. You haven’t demonstrated that your claim must be true. – DonielF Aug 20 '17 at 12:26
• “Which is a contradiction to $\gcd(a,b)$.” Why do you assume that your claim must be the correct one of the two, and not the lemma? Maybe you’ve just proven that your lemma is incorrect, rather than proving that $ab=\pm1$. – DonielF Aug 20 '17 at 12:30
• @DonielF ; If I am not mistaken, you are speaking about lemma**(I)**. Suppose on contrary; that $1 < |ab|$. So there exist a prime number $p$, which divides $ab$; i.e. $p \mid ab$. Without loss of generality we can assume that $p \mid a$. So $p$ must divides $b^2=(a^2+b^2)-a^2$. [Because $p$ divides both of the $(ab \mid a^2+b^2)$ & $a^2$.] So we can conclude that $p$ must divides $b$; which is an obvious contradiction with the assumption that $\gcd(a,b)=1$. – Davood Khajehpour Aug 20 '17 at 12:49

So $\frac{m}{n}+\frac{n}{m}=\frac{m^2+n^2}{mn}$ an integer. This means $$m^2=-n^2 \ mod \ mn$$

$$m^2+n^2=kmn$$ for some integer $k$.

If $k=1$, then $(m+n)(m-n)=0$ so $m=n$ or $m=-n$.

With some calculus, it is best shown properties about its zeros, the equation $x^2+y^2=zxy$. But there are no zeros outside of cases where $m,n=0; \ m=n; \ m=-n$.

• Maybe you can incorporate a proof that $f’(m)=0$ only when $m=-1,0,1$? (Or at least a graph?) Also, I assume $m=0$ is a maximum, as that yields $n=∞$? – DonielF Aug 20 '17 at 12:37

Suppose there does exist number $$r$$ with that property
$$r + \frac{1}{r}=n$$ $$\frac{1}{r}=n-r$$ $$n-r$$ must be an integer since both are integers.

So we are looking for $$r$$ that has a property that $$1/r$$ is an integer. It is not hard to see that it is true only for $$1,-1$$.

I think this is the easiest and best solutions ( as my classmate said everyone thinks his soultion is the best)