<s>[INST] 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?
 [/INST] First,
$$
\sqrt{\frac ab}\in\mathbb{Q}\implies\sqrt{ab}=b\,\sqrt{\frac ab}\in\mathbb{Q}\tag{1}
$$
According to this answer, since $\left(\sqrt{ab}\right)^2=ab\in\mathbb{Z}$, if $\sqrt{ab}\in\mathbb{Q}$, then $\sqrt{ab}\in\mathbb{Z}$. Thus, there is a $c\in\mathbb{Z}$ so that
$$
ab=c^2\tag{2}
$$
If $\gcd(a,b)=1$, then, by the Fundamental Theorem of Arithmetic, $(2)$ implies that both $a$ and $b$ are perfect squares.

We can avoid the Fundamental Theorem of Arithmetic by showing that if $\gcd(a,b)=1$, then Bezout's Identity says that because
$$
\begin{align}
1
&=(ax+by)^3\\
&=a^2\left(ax^3+3bx^2y\right)+b^2\left(3axy^2+by^3\right)\tag{3}
\end{align}
$$
we have $\gcd\left(a^2,b^2\right)=1$. Substituting $a\mapsto\frac{a}{\gcd(a,b)}$ and $b\mapsto\frac{b}{\gcd(a,b)}$ into $(3)$ shows that
$$
\gcd\left(a^2,b^2\right)=\gcd(a,b)^2\tag{4}
$$
Thus,
$$
a=a\gcd(a,b)=\gcd\left(a^2,ab\right)=\gcd\left(a^2,c^2\right)=\gcd(a,c)^2\tag{5}
$$
and
$$
b=b\gcd(a,b)=\gcd\left(ab,b^2\right)=\gcd\left(c^2,b^2\right)=\gcd(c,b)^2\tag{6}
$$
Therefore, $a$ and $b$ are perfect squares.
</s>