Proof Verification, $\gcd(a,b) = p$ for prime $p$ implies $\gcd(a^2,b^2) = p^2$

This is a intro to mod. alg. question which I think I have figured out, but I'm not sure if my proof is flawless, or if there's a much easier way to answer the question.

Proof:

Choose any $c$ for which $c | a^2$ and $c | b^2$. Pick any prime factor of $c$, name it $q$. Then we have
$q|c \$ and $\ c|a^2 \implies q|a^2 \implies q|a \$ since $q$ prime. Similarly, $q|b$
And since $\gcd(a,b) = p$ by assumption, then $q|p$
Since $p$ prime, $q \in \{\pm1, \pm p\}$
However, we assumed $q$ prime, and so $q \ne \pm1$, thus $q = \pm p$

The choices of $c$ and $q$ were arbitrary, therefore for any common divisor of $a^2$ and $b^2$, all of its prime factors are $\pm p$.

Thus, $\gcd(a^2,b^2) = p^k$ for some nonnegative integer $k$. We will show $k=2$
Suppose, to the contrary, that $k<2$ or $k>2$

note: $k$ must be even, since
$p^y |a \iff p^y x=a \iff p^{2y} x^2 =a^2 \iff p^{2y} |a^2$
for some $x \in \Bbb{Z}$, and assuming $a,x>0$ WLOG.

Case 1) If $k<2$ and $k$ even, then $k = 0 \implies p^k = 1$, however $p >1$ is a common divisor of $a^2$ and $b^2$, therefore $\gcd(a^2, b^2) \ge p \gt 1$, thus contradicting our assumption that $gcd(a^2,b^2) = p^k =1$, and therefore $k \not\lt 2$

Case 2) $k \gt 2$ and $k$ even implies $k \ge 4$, and so $p^4 |p^k$ and since $p^k | a^2$ by assumption, we have
$p^4 |a^2 \implies p^4z=a^2 \implies p^2 \sqrt{z} = a \implies p^2 |a$
For some $z \in \Bbb{Z}$, and note: $\sqrt{z}$ must be integral, since $p^4 z$ is a perfect square.

Similarly, $p^2 |b$, then $p^2$ is a common divisor of $a$ and $b$ and note: in general, $p^2 >p$
This contradicts our assumption that $\gcd(a,b) = p$

Hence, $k \not \gt 2$, and thus $k=2$

Therefore $\gcd(a^2, b^2) = p^2$.

• @Magdiragdag edited, thank you! – Rob Bland Sep 13 '16 at 14:31

Your proof looks correct to me, but I think I've got an easier one.

Since $\gcd(a,b)=p$, let $a=mp, b=np, \gcd(m,n)=1$. We wish to evaluate

$$k = \gcd(a^2,b^2)$$

$$k = \gcd(m^2p^2,n^2p^2)$$

$$k = p^2\gcd(m^2,n^2)$$

Since $\gcd(m,n)=1$, $\gcd(m^2,n^2)$ must also be $1$ (since $m$ and $n$ can have no common prime factors so $m^2$ and $n^2$ may not either), so we have that

$$k=p^2$$

finishing the proof. We may also note that we never used the assumption that $p$ is prime, so this works for all positive integers $p$.