Proof that the sqrt of a Natural Number is irrational outside of square numbers. I'm reading a book on Abstract Algebra and I'm covering Rings at the moment. Now I'm fairly new to this so my terminology may be incorrect, but we are looking at examples in which the set of Integers can be composed into sets with different remainders under the integer division of a Natural Number $n$
For instance if we consider Integers under the division of $3$
Here let $[n]_{m}$ is the set of Integers with remainder $n$ under integer division $m$. 
Take for instance $m = 3$, then $n = 0,1,2$
Where 
$[0]_{3} = \{ 3k \: | \: k \in \mathbb{Z} \}$
$[1]_{3} = \{ 3k + 1 \: | \: k \in \mathbb{Z} \}$
$[2]_{3} = \{ 3k + 2 \: | \: k \in \mathbb{Z} \}$
Then if we consider the Set 
$S = \{ [0]_{3}, [1]_{3}, [2]_{3} \}$
Under the definition of Addition and Multiplication as defined in the Commutative Field $\mathbb{Z}$ we see that Addition and Multiplication form a Commutative Ring on $S$. 
What I noticed however is that for an Integer $x$ that $x^{2} \in [0]_{3} \iff x \in [0]_{3}$
This got me thinking about a result I saw that for a non-square integer $p$ that $\sqrt{p} \in \mathbb{R} - \mathbb{Q}$
Applying the $\sqrt{2}$ proof of being Irrational for a non-square $p$ we assume Rationality. In the following $a,b \in \mathbb{Z}$ where $\gcd(a,b) = 1$ and $b \neq 0$ then, 
$\sqrt{p} = \frac{a}{b} \longrightarrow p = \frac{a^{2}}{b^{2}} \longrightarrow b^{2}p = a^{2}$
And so that $a^{2}$ is divisible by $p$
Now I believe that implies that $a$ must also be divisible by $p$, i.e. 
$a^{2} \in [0]_{p} \iff a \in [0]_{p}$ 
Or alternatively that $0 \equiv a^{2} \pmod p \iff 0 \equiv a \pmod p$  
I'm sure this have been proven but my limited knowledge of the field has left me not able to find the correct search terms! 
Can someone please provide a link to the proof or some hints to get started. 
Thanks 
 A: This is of course right. If $p \mid a^2$ then $p \mid a$, where $\mid $ denotes divides. This follows classically from Fundamental Theorem of Arithmetic: $a $ can be uniquely written as a product od product of powers of distinct primes (factorized):
$$a=p_1^{k_1}p_2^{k_2}\dots p_n^{k_n} $$
then we see that
$$a^2 = p_1^{2k_1}p_2^{2k_2}\dots p_n^{2k_n}$$
$p $, in order to divide $a $, must be present in that expansion. But if it is present there, it must be present in the expansion of $a$, because we haven't gained or lost any primes. Therefore $p\mid a$. End of the proof.
In the context of rings, I think it is a good idea to introduce other definition of being prime which is used in ring theory. It is more general, and it answers your question immediately: 
We say that an element $p $ of (commutative) ring $(R,+,×) $ is prime when


*

*$p$ is not zero

*$p $ does not have an inverse

*if $p \mid a×b $ then $p \mid a $ or $p \mid b $
(well, I hope you can come up with a defiinition of "$\mid$" in a abstract ring - just like in the integers)
Using this definition in the ring $\mathbb {Z} $ we see that
$$ p \mid a^2 = a×a \Rightarrow p\mid a \vee p \mid a \Rightarrow p\mid a $$
This definition has a great benefit of being general. And in the ring $\mathbb {Z} $ it is equivalent to our ordinary definition (to have exactly two divisors), and the proof of that is really similar to what we did above and also uses fundamental theorem of arithmetic. 
