Find the greatest common divisors I am given the following exercise:


*

*If $p$ is a prime and $(a,b)=p$,calculate $(a^2,b^2), (a^2,b)$


That's what I have tried:


*

*Both $a$ and $b$ contain $p$ and at least one of them contains $p$ with exponent $1$.
The two canonical forms of $a$ and $b$ have not an other common prime.
So,it can be 


*

*$a=p \cdot p_1^{a_1} \cdot p_2^{a_2} \cdots p_k^{a_k} \text{ and } b=p^{d} \cdot q_1^{d_1} \cdot q_2^{d_2} \cdots q_m^{a_m}$ 

*$a=p^{a_0} \cdot p_1^{a_1} \cdots p_k^{a_k} \text{ and } b=p \cdot q_1^{b_1} \cdots q_m^{b_m}$
where $p_i \neq q_j \forall i,j$
So:


*

*$(a^2,b^2)=p^{\min\{2,2d \}}=p^2$

*$(a^2,b^2)=p^{\min \{ 2,2a_0\}}=p^2$


*

*$(a^2,b)=\left\{\begin{matrix}
p,d=1\\ 
p^2,d \geq 2
\end{matrix}\right. $

*$(a^2,b)=p$
Could you tell me if it is right?
 A: Yes, $(a^2,b^2)=p^2$ which is obtained by counting powers of $p$ in $a^2$ and $b^2$.
For $(a^2,b)$ there are two answers:
$$
(a^2,b)=p^2,\, \mathrm{ for\, example,\, } a=p,\ b=p^2,
$$
$$
(a^2,b)=p,\, \mathrm{ for\, example,\, } a=p,\ b=p.
$$
There is no more cases, because $(a^2,b)|(a^2,b^2)$ and $(a,b)|(a^2,b)$. Hence $(a^2,b)$ is $p$ or $p^2$.
A: Your answer is correct. You may find it instructive to compare it to this more general method. 
Note $\ \ (A,B) = p\iff A,B = pa,pb,\  (a,b) = 1.$
Thus $\,(A^2,B) = (p^2 a^2,pb) = p(p\color{#0a0}{a^2,b}) = p\color{#c00}{(p,b)},\ $ by $\,(a,b)=1\,\Rightarrow\,\color{#0a0}{(a^2,b)=1}\,$ by Euclid's Lemma.
So $\,\ (A^2,B^2) = (p^2a^2,p^2b^2) = p^2(a^2,b^2) = p^2,\ $ by $\,\color{#0a0}{(a^2,b)=1}\,\Rightarrow\,(a^2,b^2)=1\,$ by Euclid's Lemma.  
Remark $\ $ Notice that the above method eliminates the case analysis, reducing it to $\, \color{#c00}{(p,b)} = p\,$ or $\,1\,$ if $\,p\,$ is prime. But the above proof works for any $\,p.$ In fact the above proof works more generally in any gcd domain, i.e. any domain where gcds exist. This is more general than using the existence and uniqueness of prime factorizations, since some gcd domains have no primes at all, for example the ring of all algebraic integers, where $\,\alpha \,=\, \sqrt \alpha\sqrt \alpha,\,$ so there are no irreducibles, so no primes.
