What rational numbers have rational square roots? All rational numbers have the fraction form $$\frac a b,$$ where a and b are integers($b\neq0$).
My question is: for what $a$ and $b$ does the fraction have rational square root? The simple answer would be when both are perfect squares, but if two perfect squares are multiplied by a common integer $n$, the result may not be two perfect squares. Like:$$\frac49 \to \frac 8 {18}$$
And intuitively, without factoring, $a=8$ and $b=18$ must qualify by some standard to have a rational square root.
Once this is solved, can this be extended to any degree of roots? Like for what $a$ and $b$ does the fraction have rational $n$th root?

Trivially, a rational number has a rational square root if and only if it's the square of some rational number.
As the other answers note, various other characterizations can be given, e.g. that $\frac ab$ has a rational square root if and only if:


*

*$a = ec^2$ and $b = ed^2$ for some integers $c$, $d$ and $e$,

*the numerator and denominator of the reduced form of $\frac ab$ are both squares, or

*the unique prime factorization of $\frac ab$ has only even exponents.


Yet another "cute" characterization is that $\frac ab$ has a rational square root if and only if $ab$ is a square of an integer.  I've sketched a proof of this below.

Proof. To show that this rule works, first note that, if $a = ec^2$ and $b = ed^2$, then $ab = c^2d^2e^2 = (cde)^2$.  Showing the converse is a bit trickier, but it follows easily enough from prime factorization.  Specifically, let
$$ ab = x^2 = y = \prod_{i=1}^\infty p_i^{y_i}
,\quad
a = \prod_{i=1}^\infty p_i^{a_i}
\quad\text{and}\quad
b = \prod_{i=1}^\infty p_i^{b_i} $$
where $p_i$ denotes the $i$-th prime.  Since $y = x^2$ is a square, we know that $y_i$ must be even for all $i$; from $y = ab$, we know that $y_i = a_i + b_i$ for all $i$.  Together, these imply that, if $a_i$ is odd for some $i$, so is $b_i$, and the converse also holds.
Now let $$e = \prod_{i=0}^\infty p_i^{e_i},$$
where $e_i = 1$ if $a_i$ and $b_i$ are odd, and let $e_i = 0$ if they are even.  Since $e_i \le a_i$ and $e_i \le b_i$ for all $i$, $e$ divides both $a$ and $b$.  Furthermore, since $a_i - e_i$ and $b_i - e_i$ are both even for all $i$, it follows that $a/e = c^2$ and $b/e = d^2$ are both squares, and so we can write $a = ec^2$ and $b = ed^2$. $\square$

Ps. As Akiva Weinberger notes in the comments below, this "trick" can also be generalized to higher powers.  Specifically, $\frac ab$ has a rational $n$-th root if and only if $a^{n-1} b$ (or, equivalently, $b^{n-1} a$) is an $n$-th power of an integer.
