Fixed LCM and GCD functions