least common multiple formula knowing gcd code example Example: least common multiple algorithm lcm = a / gcd * b;