Looking for an error in a simple proof

Assume n is an integer. If the square root of $n$ is rational, prove that $n$ is a perfect square.

To prove the above statement, I used a trick rather than the standard way of using the unique factorization theorem over the field of integers. My professor claims that my proof is wrong but I don't know where it went wrong. The proof is as follows:

If $\sqrt{n}$ is rational, then there exists integers $p,q$ with $\gcd(p,q) = 1$ such that $\sqrt{n} = \dfrac{p}{q}$.Therefore by multiplying both sides by $\sqrt{n}$ I obtain $n = \dfrac{p}{q}\sqrt{n}$ or $\sqrt{n} =\dfrac{q *n}{p}$. Since $\sqrt{n} = \dfrac{p}{q}$ and $\sqrt{n} = \dfrac{q *n}{p}$, we can deduce that $\dfrac{p}{q} = \dfrac{q *n}{p}$. I believe the proof is fine up to this part.

Now I claim the following: Since $\gcd(p,q) = 1$, $\frac{p}{q}$ is in lowest terms. Since $p,q,n$ are all positive integers, there must exist some positive integer $r$ such that $p*r = q*n$ and $q *r = p$. (I believe this is the fishy part. Perhaps this can't be justified straight from definition of equivalence classes?).

As such, we know $q*r = p$ or $r = \dfrac{p}{q} = \sqrt{n} \implies r^2 = n$. Since $r$ is an integer, $n$ must be a perfect square.

Where did my proof go wrong?

• Your fishy part is indeed wrong. You can only find $r,s\geq 1$ so that $p\cdot r=q\cdot n\cdot s$ and $q\cdot r=p\cdot s$. – Ian Coley Apr 3 '14 at 6:32
• @IanColey even if $\dfrac{p}{q}$ are in lowest terms? Is there a counterexample? – user135562 Apr 3 '14 at 6:33
• You have got $p^2=q^2n$. Show that this implies $q=1$. – Macavity Apr 3 '14 at 6:36
• @IanColey I disagree with your comment. If $p/q$ is in lowest terms, the OP's argument is correct. – Did Apr 3 '14 at 6:40
• @Macavity I understand the standard argument. I'm just wondering why this approach fails. My professor said that it's because it wouldn't be possible to prove this without using the unique factorization theorem, but I can't figure out why this approach is incorrect. Perhaps I used the unique factorization theorem without realizing it? – user135562 Apr 3 '14 at 6:57

Since $p,q,n$ are all positive integers, there must exist some positive integer $r$ such that $p*r = q*n$
It is only true when $p\leqslant q*n$.
and $q *r = p$.
It is only true when $p\geqslant q$.
And you didn't the $r$s are the same.