TITLE: $2d^2=n^2$ implies that $n$ is multiple of 2
QUESTION [6 upvotes]: I'm reading a proof of the irrationality of $\sqrt 2$. In a step it states that $2d^2=n^2$ implies that $n$ is multiple of 2. How?

REPLY [7 votes]: If $n^2 = 2d^2$, then $n^2$ is a multiple of $2$ hence even.
We now prove: $n^2$ even implies $n$ even.
Proof: We tackle the contrapositive, i.e., $n$ odd implies $n^2$ odd.
Since $n$ is odd, we can write $n = 2k+1$ for some integer $k$.
Then $n^2 = (2k+1)^2 = 4k^2 + 4k + 1 = 2(2k^2 + 2k) + 1$, which is an odd number.
(It's of the form $2m + 1$ for an integer $m = 2k^2 + 2k$.)
This completes the proof, and the contrapositive is the statement you asked about. QED

REPLY [3 votes]: It works for any prime $p$:
$$p|n^2 \Rightarrow p|n$$
This is because of the uniqueness of prime factor decomposition.