If $p$ is prime, show that $p\mid a^2 \implies p\mid a$ This might seem like a trivial question, but I am not very good at mathematics. If I am supposed to show that: 

If $p$ is prime show that $p\mid a^2 \implies p\mid a$

I would do like this (I do not even know if it is a valid way to show the statement);
If $p$ is prime then $p\mid p$. So if $p\mid a^2$ it means that $a^2$ must have at least one factor $p$ such that $p\mid a^2$ and due to the fact that $a^2 = a \times a$, it follows that $p = a$. Thus $p\mid a$. 
But that is not a formal proof, right? It is more like an informal proof. So my question is if there is a more formal approach to show that:

If $p$ is prime show that $p\mid a^2 \implies p\mid a$

I know that there exist different methods to show divisibility, but due to the obviousness of the statement I have a very hard time showing the statement without using a lot of words.
 A: As $p|a^2$ we write $a^2=pb$. As the left hand side is a square, we write $b=pc^2$. Therefore $a^2=p^2c^2\to a=pc$, hence $p|a$.
A: A quick proof. Since $\textbf{F}_p=\textbf{Z}/p\textbf{Z}$ is a field, and $a^2=0$ in $\textbf{F}_p$, we have $a=0$ in $\textbf{F}_p$.
A: If P doesn't divide a, then
a=m.p, where m is a non integer rational number.
Multiplying a both sides
a^2 = m.a.p
m.a will still be a non integer  rational number. Since m has p in denominator and p cannot divide a. So a^2 has non integer quotient when divided by p.
Hence p should divide a, for it to divide a^2.
A: Suppose that $p\not\mid a$. Then $p$ is not in the factorization of $a$. Since $a^2$ has the same factors as $a$ with exponents doubled, $p$ is not in the factorization of $a^2$, so $p\not\mid a^2$. Contradiction.
A: Using the fundamental theorem of arithemtic, $a$ is the unique product of $k$ primes
$$a = \prod_{i=1}^k p_i^{\alpha_i} = p_1^{\alpha_1}p_2^{\alpha_2} \cdots p_k^{\alpha_k}$$
Then we can write 
$$a^2 = \prod_{i=1}^k p_i^{2\alpha_i} = p_1^{2\alpha_1}p_2^{2\alpha_2} \cdots p_k^{2\alpha_k}$$
Now if $p\ |\ a^2 = \prod_i p_i^{2\alpha_i}$, then $p$ must be one of the $p_i$ since the prime factorization is unique.
Therefore we have $p\ | \ \prod_i p_i^{\alpha_i} = a$.

Let's apply this to a simple example. Let $p = 3$ and $a = 60$. Then
$$a = 2^2 \cdot 3 \cdot 5 \text{ and } a^2 = 2^4 \cdot 3^2 \cdot 5^2$$
Since $3$ divides $a^2$ we know that $3$ is one of the primes in the factorization of $a^2$. Thus $3$ is also one of the primes in the factorization of $a$ and therefore divides $a$.
A: Suppose $p \nmid a$ then we know that $p$ and $a$ have no common factor and hence their GCD is $1$. Therefore there are integers $x, y$ with $px + ay = 1$. Now multiplying by $a$ we get $$apx + a^{2}y = a$$ and since $p \mid a^{2}$ we have an integer $n$ such that $a^{2} = np$ and hence $$apx + npy = a$$ or $$p(ax + ny) = a$$ so that $p \mid a$ and we reach a contradiction. It follows that $p \mid a$.
A: An elementary proof, without the fundamental theorem of arithmetic.
This proof only uses  $\mathbf N$ being well ordered and its consequence: Euclidean division.
Consider the set $\;E=\bigl\{x\in \mathbf N^*\enspace\text{such that}\enspace p\mid xa\bigr\}$.
This set is not empty, since it contains $p$ and $a$. So it contains a smallest element, $b$.
Claim: $\;b$ divides every element of $E$.
Indeed, let $x$ be any element of $E$. Euclidean division gives equality $\;x=qb+r$, $\;0\le r<b$. As $x$  and $b$ lie in $E$, so does $r$, unless $r=0$. But this is impossible, since $b$ is the smallest element of $E$. Thus, $r=0$, i.e. $b$ divides $x$.
In particular, $b$ divides $p$. As $p$ is prime, this means $b=1$ or $b=p$.
If $b=1$, by definition of $E$, it means $p$ divides $1\cdot a=a$.
If $b=p$, $\;p$ divides $a$ by the claim, since $a\in E$.
A: First of all, if one assumes ring-theoretic definition of prime, this whole exercise is trivial. So, we obviously won't, we will assume that "prime" means positive integer with exactly two divisors in $\Bbb N$.
One needs to be careful not to fall into circularity here, so let me introduce terminology.


*

*We will call positive integer $p$ $\Bbb N$-prime if $p$ has
exactly two divisors in $\Bbb N$.

*We will call (integer) $x$ prime if $x\mid ab\implies x\mid a$
or $x\mid b$.

*We will call $x\in \Bbb Z\setminus\{0,\pm 1\}$ irreducible if
$x = ab\implies a =\pm 1$ or $b = \pm 1$.
Thus, we can reformulate your exercise as 

Every $\Bbb N$-prime $p$ is prime in $\Bbb Z$.

because we would then have $p|a^2 \implies p\mid a$ or $p\mid a$.


Lemma. $x$ is irreducible in $\Bbb Z$ if and only if $|x|$ is $\Bbb N$-prime.

Proof. Assume that $x$ is irreducible and that $d\mid |x|$ in $\Bbb N$. Then $x = \pm nd$ for some $n\in\Bbb N$, but since $x$ is irreducible, $d = 1$ or $n= 1$, i.e. $d = 1$ or $d = |x|$.
Conversely, if $|x|$ has exactly two divisors in $\Bbb N$, and $x = ab$, then $|a|,|b|\in\{ 1,|x|\}$, but that means that either $a = \pm 1$ or $b=\pm 1$.

In general, we know that every Euclidean domain is unique factorization domain, and also, we know that in UFD $x$ is prime if and only if $x$ is irreducible.
Thus, if we can prove that $\Bbb Z$ is Euclidean domain, then it is UFD, and thus if $p$ is $\Bbb N$-prime, it is irreducible in $\Bbb Z$ by our Lemma, and hence prime, which would finish the proof by the above remark.

Theorem. $\Bbb Z$ is Euclidean domain with Euclidean function $f\colon\Bbb Z\setminus\{0\}\to \Bbb N$, $f(x) = |x|$.

Sketch of proof. Let $a,b\in\Bbb Z$ with $b\neq 0$. For simplicity let us assume that $a,b>0$.
We want to show that there exists $q,r\in \Bbb N$ such that $a = bq + r$ and $0\leq r < b$. Let us define $q = \min\{n\in\Bbb N\,|\, nb > a\} - 1$ (existence of $q$ is guaranteed by well-ordering of $\Bbb N$) and define $r = a - bq$. Then we have $$bq \leq a < b(q+1)\implies 0\leq a - bq < b \implies 0\leq r < b.$$
General case where $a,b$ are not necessarily positive can be deduced from this by playing with absolute value.
Of course, for $a,b\neq 0$, $f(a)\leq f(ab) \iff |a| \leq |ab| \iff 1\leq |b|$ and we are done.
