'Return Factors of ``lcm(self, other)`` which are
the union of factors with the maximum exponent for
each factor.
Examples
>>> from sympy.core.exprtools import Factors
>>> from sympy.abc import x, y, z
>>> a = Factors((x*y**2).as_powers_dict())
>>> b = Factors((x*y/z).as_powers_dict())
>>> a.lcm(b)
Factors({x: 1, y: 2, z: -1})'

def lcm(self, other):

    if (not isinstance(other, Factors)):
        other = Factors(other)
        if any((f.is_zero for f in (self, other))):
            return Factors(S.Zero)
    factors = dict(self.factors)
    for (factor, exp) in other.factors.items():
        if (factor in factors):
            exp = max(exp, factors[factor])
        factors[factor] = exp
    return Factors(factors)
