TITLE: If we know the GCD and LCM of two integers, can we determine the possible values of these two integers?
QUESTION [6 upvotes]: I know that $\gcd(a,b) \cdot \operatorname{lcm}(a,b) = ab$, so if we know $\gcd(a,b)$ and $\operatorname{lcm}(a,b)$ and we want to find out $a$ and $b$, besides factoring $ab$ and find possible values, can we find these two integers faster?

REPLY [3 votes]: There are $2^m$ possible answers, where $m$ is the number of distinct primes dividing the ratio of LCM to GCD. If
$$
\eqalign{
 \text{gcd}(x,y) &= \prod p_i^{a_i} \\
 \text{lcm}(x,y) &= \prod p_i^{b_i}
}
$$
(with $a_i\le b_i$)
and
$$
\eqalign{
 x &= \prod p_i^{c_i} \\
 y &= \prod p_i^{d_i}
}
$$
then each $c_i$ is either $a_i$ or $b_i$, and each $d_i$ must be the other one.
This is because $a_i=\min(c_i,d_i)$ and $b_i=\max(c_i,d_i)$. To invert this process, we have more than one solution whenever $a_i\ne b_i$.
This gives two choices for each of the $m$ values of $i$ where $a_i<b_i$, or $2^m$ total possibilities.