Is $\sqrt{m}$ irrational iff at least one prime occurs with an odd exponent in the factorisation of $m$? Thinking about it, I think I found the following criterion for irrationality of $\sqrt{m}$ if $m$ is a positive integer.

Let $p_1^{a_1}\cdots p_k^{a_k}$ be the prime factorization of $m$. Then $\sqrt{m}$ is irrational if and only if $a_i$ is odd for at least one $1\le i\le k$.

Anyone knows if this is correct and, if so, a proof thereof?
 A: Yes this is true. A nice way to think about this, is that if you extend the notion of prime factorisation to allow for negative exponents, you can show that all rational numbers have a unique prime factorisation as well. Then if you square a rational number of the form $r=p_1^{a_1}\cdots p_k^{a_k}$, where $a_i\in\mathbb{Z}$, then the square of this has the unique prime factorisation
$$r^2=p_1^{2a_1}\cdots p_k^{2a_k}$$
So the square of any rational number has only even exponents in its prime factorisation. The converse is pretty obvious.
Note that from this line of thinking its easy to see that if $m$ is an integer, then $\sqrt{m}$ is either irrational or an integer too.
A: This is correct. Since for any $p_i$ with power $a_i\geq 2$ you can put all except perhaps one outside the square root, it's enough to consider numbers where each prime factor has power $1$ (the so-called square free numbers). Thee question then translates to "The only square free number that has a rational square root is $1$" (I don't really know if $1$ is considered a square free number).
A variant on the proof of the irrationality of $\sqrt2$ works fine.
