I have just given it a try in Ruby

def fibonacci_numbers(upto) sequence = [0, 1] loop do next_number = sequence[-2] + sequence [-1] sequence.push next_number if next_number < upto break unless next_number < upto end sequence end def sum_of_even_numbers(upto) sequence = fibonacci_numbers(upto) sequence.select{ |el| el % 2 == 0 }.reduce(:+) end puts sum_of_even_numbers(4000000)

We're a place where coders share, stay up-to-date and grow their careers.

We strive for transparency and don't collect excess data.

## re: Project Euler #2 - Even Fibonacci numbers VIEW POST

FULL DISCUSSIONI have just given it a try in Ruby