DEV Community

Discussion on: Project Euler #2 - Even Fibonacci numbers

Collapse
 
hanachin profile image
Seiei Miyagi

Ruby✨💎✨

puts Enumerator.new { |y|
  f1, f2 = 0, 1
  f1, f2 = f1 + f2, f1 while y << f1
}.take_while {|x| x <= 4_000_000 }.select(&:even?).sum