Given two numbers, there is a largest number that divides both of them and a smallest number that both of them divide. Neither has to be hunted for. Once you have the prime decompositions, both are read straight off.
You have learned that every natural number has exactly one
prime decomposition. That fact is what makes this module easy. Write two
numbers as products of primes, set the lists side by side, and the two answers are
sitting there: one takes the primes the lists
share, the other takes every prime
that appears in
either list.
The two names are worth pinning down, because they sound alike and mean opposite things.
The
greatest common divisor, also called the greatest common factor, is
a number you
divide by, so it is never larger than the numbers you started with.
The
least common multiple is a number you
count up to, so it is
never smaller than them. If your GCD comes out bigger than either number, or your LCM
smaller, you have swapped them.