Euclid's GCD algorithm. LCM too.