Fixed error with computing lcm