Show that $\sqrt{p}$ is irrational if $p$ is prime

Show that $\sqrt{p}$ is irrational if $p$ is prime.

I did the proof before that $\sqrt{2}$ is irrational by contradiction:

Let's assume that $\sqrt{2}$ is rational, therefore given $m$ and $n$ sharing no common factor: $$\sqrt{2} = \frac{m}{n}$$ $$2=\frac{m^2}{n^2}$$ $$2n^2=m^2$$

As $2 \mid 2n^2$ , it follows that $2 \mid m^2$, and that $2\mid m$. Therefore $\exists k \in Z$ s.t. $m=2k$

Using back $2n^2=m^2$ and substituting $m=2k$ in it, we have: $$2n^2=(2k)^2$$ $$2n^2=4k^2$$ $$n^2=2k^2$$

Similarly, as $2 \mid 2k^2$, it follows that $2 \mid n^2$, and that $2 \mid n$. Therefore, $\exists j \in Z$ s.t. $n=2j$

Finally, if $m=2k$ and $n=2j$ $n,j \in Z$, $m$ and $n$ share a common factor $2$. We have a contradiction with the assumption.

It follows that $\sqrt{2}$ cannot be rational but irrational.

This is where I am so far with my understanding. What would the best approach be with the original question?

What would be the approach be here? I was thinking to state that if $p$ is composite then $\exists x,y,m,n \in Z$, all four prime numbers, s.t. $p=xy$.and have then $$\sqrt{xy}= \frac{m}{n}$$ but I don't see how I could move forward in this direction.

Much appreciated

• A more general statement here math.stackexchange.com/questions/2126586/… – rtybase Jun 3 '17 at 23:19
• Why assume p is composite? If you are trying to do a proof by contradiction, there is nothing that will contradict. Composite numbers may or may not have rational square roots and will tell you nothing about the roots a prime will have. Also if p=xy x and y don't have to be prime there's no reason why m,n must be prime either. That statement is simply wrong. – fleablood Jun 3 '17 at 23:58

Why not just try the same thing? Assume $\sqrt{p} = \frac{m}{n}$ for coprime $m,n$. Then $p = m^2/n^2 \implies m^2 = pn^2$. Hence $p \mid m^2 \implies p \mid m$ by Euclid's Lemma. Then $p \mid n^2 \implies p \mid n$. Contradiction.
• Sir contradiction to what? I think to "$m$ and $n$ are coprime" ? (Since they are coprime so they don't have divisor $>1$) am i correct? – Akash Patalwanshi Dec 8 '19 at 16:27
More is true: If $n$ is not the square of an integer, then $\sqrt{n}$ is irrational.
Follow-up Question: Proof of Irrationality of $\sqrt{3}$