re: Project Euler #1 - Multiples of 3 and 5 VIEW POST

FULL DISCUSSION
 

Ruby✨💎✨

require "set"

multiples_of_3 = Enumerator.new {|y| x = 0; y << x while x += 3 }
multiples_of_5 = Enumerator.new {|y| x = 0; y << x while x += 5 }

puts [multiples_of_3, multiples_of_5].each_with_object(Set.new) { |e, s|
  s.merge(e.take_while(&1000.method(:>)))
}.sum
code of conduct - report abuse