I'm trying to prove that $\sqrt{p}$ is irrational for prime $p$. I know how to prove the result when $p = 2$, but I'm not fully certain that every element of my proof generalizes to the case where $p$ is a general prime. In particular, I wrote the proof a bit differently. I'd appreciate if someone could provide some feedback on my proof.
Suppose for the sake of contradiction that $\sqrt{p}$ were rational. Then $\sqrt{p} = \frac{m}{n}$ for some $m,n \in \mathbb{Z}$. Since $q^2 = (-q)^2$ for any $q \in \mathbb{Q}$ and $\sqrt{p} > 0$, we may assume that $m$ and $n$ are positive. Furthermore, cancelling any common prime factors, we can assume without loss of generality that $m$ and $n$ share no common factors other than $1$. Then $p = \left(\frac{m}{n}\right)^2 = \frac{m^2}{n^2}$, so $pn^2 = m^2$. As $p \mid m^2$, one has $p \mid m$; if $p \nmid m$, then $p \nmid m^2$ by the fundamental theorem of arithmetic. So $pk = m$ for some $k \in \mathbb{Z}$. Then $pn^2 = (pk)^2 = p^2 k^2$ and hence $n^2 = pk^2$. Therefore, $p \mid n^2$ and hence $p \mid n$, contradicting the fact that $m$ and $n$ were relatively prime. Therefore, $\sqrt{p}$, which cannot be written as a ratio of integers, is irrational.
How does this look?