Solution (source code)

= Solution

Write $a=\prod_pp^{r_p}$ and $b=\prod_pp^{s_p}$. Divisibility is exactly comparison of <prime exponents>. Thus the <greatest common divisor> uses $\min(r_p,s_p)$ and the <least common multiple> uses $\max(r_p,s_p)$. Since their sum is $r_p+s_p$ for each prime,
$$
\boxed{\gcd(a,b)\operatorname{lcm}(a,b)=\prod_pp^{r_p+s_p}=ab.}
$$