What are the possible values for $\gcd(a^2, b)$ if $\gcd(a, b) = 3$? I was looking back at my notes on number theory and I came across this question.
Let $a$, $b$ be positive integers such that $\gcd(a, b) = 3$. What are the possible values for $\gcd(a^2, b)$?
I know it has to do with their prime factorization decomposition, but where do I go from here?

We know that among all the divisors of $b$, only 3 divides $a$. There are two cases: 1) 3 divides $b$ only one time xor 2) 3 divides $a$ only one time (and $b$ more then once!). 1) $GCD(a^2,b)$ is 3. 2) 3 divides $a^2$ two times, so $GCD(a^2,b)$ is $3^2=9$.
EDIT:
I think I need to add the general law, which is extensively used here and enables short reasonings. Let $\{ p_i\}$ be the set of all the prime divisors of $a$ or $b$. Then we have:

If $a=\prod_{i=1}^n p_i^{q_i},\ b=\prod_{i=1}^n p_i^{r_i}$ (some of $q_i,\ r_i$ might be equal to zero), then
  $$GCD(a,b) = \prod_{i=1}^n p_i^{min(r_i,q_i)}.$$

