class Array
  def lcm
    self.inject do |a, b|
      a*b/self.gcd
    end
  end

  def gcd
    self.inject do |a, b|
      a, b = b, a if a < b
      return a if b == 0
      arr = b, a%b
      arr.gcd
    end
  end
end