Show that $\sqrt{q}$ is irrational 
Let q be a positive integer such that $q \geq 2$ and such that for any
  integers a and b, if $q|ab$, then $q|a$ or $q|b$. Show that $\sqrt{q}$
  is irrational.

Proof;
Let assume $\sqrt{q}$ is a rational number, where $n \neq 0$ and $\gcd (m,n)=1$, meaning $\sqrt{q} = \frac{m}{n}   \Rightarrow q=\frac{m^2}{n^2} $
Since $n^2 \nmid m^2$, $q|m^2 \Rightarrow q|m$, so $m=qt$ where $t\in \mathbb{Z}$
By substitute $m=qt$ in the equation $qn^2 = m^2$, we get $n^2=qt^2$.
Since tells us that $q|n^2$ and $t^2|n^2$, it contradicts with the assumption $\gcd (m,n)=1$; therefore, $\sqrt{q}$ is irrational.
I get this proof with the assistant of the course, but is there any flaw or mistake? What are the other methods for proving this statement, can you at least give one different method? And how can I improve this proof?
 A: Proof using Bézout's Identity
For $\sqrt{q}$ to be irrational, $q$ must not be a perfect square. Thus, we only concern us with non-perfect square $q$.
Assume that $\sqrt{q}$ is rational. Therefore $\sqrt{q} = \frac{m}{n}$ where $\gcd{(m, n)} = 1$.
By Bézout's Identity, there exist integers $x$ and $y$ such that $mx + ny = 1$
Now $\sqrt{q} = \sqrt{q}(1) = \sqrt{q}(mx + ny) = (\sqrt{q}m)x + (\sqrt{q}n)y = qnx + my = \text{an integer}$
Which leads us to a contradiction, since we initially assumed that $q$ wasn't a perfect square. Hence, $\sqrt{q}$ is irrational.
A: We just have to show that for any prime number $p$, $\sqrt{p}\not\in\mathbb{Q}$.
If we assume $\sqrt{p}=\frac{a}{b}$ with $a,b\in\mathbb{Z}^+$ we get the identity $pb^2=a^2$.
For any $n\in\mathbb{Z}^+$, let $\nu_p(n)=\max\{m\in\mathbb{N}: p^m\mid n\}$. The identity $pb^2=a^2$ implies
$$ \nu_p(pb^2) = \nu_p(a^2) $$
but that is impossible, since $\nu_p(a^2)$ is an even number and $\nu_p(pb^2)=1+\nu_p(b^2)$ is an odd number. $\sqrt{p}\not\in\mathbb{Q}$ trivially follows.
