Is this number theory proof correct? (irrationality of $\sqrt n$) I read the following proof in a book while I seeing the proof that  is irrational if $n$ is not a perfect square number. The proof is as follows-

Let, if possible, there exists rational number $\frac pq$=$\sqrt n$ ($p $ and $q$ are co-prime). Squaring both sides $p^2=n*q^2$.
From above we get $n$ is a factor of $p^2$. Now, it is written that we can deduce $n$ is a factor of $p$.

Similarly it is also proved that n is a factor of q. From that we get that $p$ and $q$ both have some common factor $n$ which contradicts the hypothesis that $\frac pq$ is co-prime. So our assumption was wrong.
Now, my question is, how can it be said that if $n$ is a factor of $p^2$ it will also be a factor of $p$? Take an example- $72$ is a factor of $12^2=144$ but it is not a factor of $12$.
Where am I wrong? Please explain.
 A: The correct proof would be as follows :
Assume , $n>1$ is not a perfect square. Then, there exists a prime factor $s$, for which the exponent in the prime factorization is odd. Now, assume
$p^2=nq^2$ with $(p,q)=1$. Then it follows that $s$ divides $p$. But the exponent
of $s$ in the left number is even, the exponent of $s$ in the right number is odd.
So, the numbers cannot coincide.
A: The proof is wrong and you have given a correct counter-example.
The theorem, however, is correct. One way to prove it (besides the countless existing ones you see on this same question in Math SE) is as follows:
$p^2 = \gcd(p^2,nq^2) \mid \gcd(p^2,n) \gcd(p^2,q^2) \mid \gcd(p^2,n) \gcd(p,q)^2 = \gcd(p^2,n)$
Thus $p^2 \mid n$, which since $p^2 = n q^2$ implies that $q^2 = 1$ and hence $n = p^2$.
A: An elementary proof (only based on the property that a non-empty set of natural numbers has a smallest element).
By contraposition: let $x = \sqrt{n}$ and let $y$ be its decimal part: $y=x-\lfloor x\rfloor$. Suppose $x$ is rational; all we must show is $\;y = 0$.
$\{\,k\in\mathbf N*\mid qx\in \mathbf N\,\}\neq\varnothing\;$ since it contains at least the denominator of $x$. Let $q$ the smallest such number. Then $\;q' = qy\;$ is an integer too. On another hand,
    $$ q'x = q( x-\lfloor x\rfloor)x = qx^2 - \lfloor x\rfloor qx=qn-\lfloor x\rfloor q, $$
which shows $q'x$ is an integer. However $q$ is the smallest positive integer with this property, and $\,0 \le q' < q\,$ since $0\le y<1\,$; thus $q' = 0$, whence $y = 0$.
