function gcd m, n repeat while m is greater than 0 put m into temp put n modulo m into m put temp into n end repeat return n end gcd function lcm m, n return m divided by gcd(m, n) times n end lcm