Let $n \in \mathbb{N}$ such that n is a non-perfect square. Show that $\sqrt{n}$ is irrational. Can someone please check my proof?
Let $n \in \mathbb{N}$ such that n is a non-perfect square. Show that $\sqrt{n}$ is irrational.
Let's prove it by contradiction, that is, suppose there are $n,a,b \in \mathbb{N}$ such that $\frac{a}{b}=\sqrt{n}$, n is a non-perfect square and there are no common factors for a and b, that is, they are coprime. n is either even or odd. Suppose n is even, that means $n=2k$ for some $k \in \mathbb{N}$. Therefore:
$$
\begin{align*}
\frac{a^2}{b^2}&=2k\\
a^2 &= 2k\cdot b^2 = 2(k\cdot b^2)
\end{align*}
$$
Which means that $a^2$ is even and therefore a is even and that means that there is some $j\in \mathbb{N}$ such that $a=2j$. Plugging in that value for a:
$$
\begin{align*}
\frac{2j}{b^2}&=2k\\
4j^2 &= 2k\cdot b^2 \rightarrow b^2 = 2\big(\frac{2j^2}{k}\big)
\end{align*}
$$
Using the same reasoning b is also even. That contradicts the fact that a and b are coprime and therefore $\sqrt{n}$ is irrational.
Now suppose n is odd, that means that $n=2k+1$ for some $k\in \mathbb{N}$. Therefore:
$$
\begin{align*}
\frac{a^2}{b^2}&=2k+1\\
a^2 &= (2k+1)\cdot b^2 \rightarrow (2k+1)|a^2
\end{align*}
$$
Since $(2k+1)|a^2$ we can conclude that $a^2 = q(2k+1)$. Plugging in that value for a:
$$
\begin{align*}
\frac{q(2k+1)}{b^2}&=2k+1\\
q(2k+1) &= (2k+1)\cdot b^2 \rightarrow q=b^2
\end{align*}
$$
That way q is a common factor for a and b, which contradicts the fact that they are coprime, hence $\sqrt{n}$ is irrational.

Is my reasoning correct? I've seen easier and shorter proofs, by I tried to generalize the reasoning that I used to prove that $\sqrt{2}$ and $\sqrt{3}$ are irrational...
Thank you for reading it!

As the comments suggest, you overanalyze. If $\frac{a}{b}=\sqrt{n}$ then $\frac{a^2}{b^2}=n$ and $a^2=nb^2$. Thus, as with the cases of $2$ and $3$, $n\mid a^2$. Now, for every prime factor $p_i$ of $n$, if $p_i\mid a^2$, then $p_i\mid a$. Thus $(p_i)^2\mid a^2$. Remove that $p_i$ from each occurrence of $n$ and $a$, and you are left with the fact that $\frac{n}{p_i}\mid \frac{a^2}{(p_i)^2}$. Repeat for every other prime factor of $n$ to arrive at the fact if $n\mid a^2$ then $n\mid a$. So $a=kn,a^2=k^2n^2$, and from here the proof is the same as for $2$ and $3$ in that you can show that $n$ must be a factor of $b$.
