Here is an explicit description of the gcd and lcm in terms of prime factorizations.

Theorem

If a and b are positive integers, then

gcd(a,b) = prodp prime pmin{ordp(a),ordp(b)} ,

lcm(a,b) = prodp prime pmax{ordp(a),ordp(b)}.

In particular we have    a · b = ggd(a,b) · lcm(a,b).