[Math] Showing that if $\sqrt n$ is rational if and only if $n$ is a perfect square

number theory

Let $n$ be an integer. Show that $\sqrt{n}$ is rational if and only if $n$ is a perfect square (i.e., the square of an integer).

How would I do this proof. In a simple manner.

If n is perfect square then the square root n is a rational number.

So if n is a perfect square there is a integer m such that $m(m)=n^2$

So then I guess I can do the logik from contrapostive.

If square root of n is irrational then not n is perfect square.

But how could I prove this?

Best Answer

Let $n\in\mathbb{N}$.

$\implies$ If n is a perfect square, then $n=m^2$ for some $m\in\mathbb{N}$, so $\sqrt{n}=m$ is rational.

$\impliedby$ If $\sqrt{n}$ is rational, let $\sqrt{n}=\frac{a}{b}$ where $a,b\in\mathbb{N}$ and $\text{gcd} (a,b)=1$.

$\hspace{.4 in}$Then $n=\frac{a^2}{b^2}$ gives $a^2=nb^2$; so if $p$ is a prime and $p\big|b$, then $p\big|a^2$ and therefore $p\big|a$.

$\hspace{.4 in}$This gives a contradiction, since $\text{gcd}(a,b)=1$;

$\hspace{.4 in}$so $b=1$ (since it has no prime divisors) and therefore $n=a^2$ is a perfect square.

Related Question