Skip to content

Instantly share code, notes, and snippets.

@dbyrne
Created June 4, 2010 01:25
Show Gist options
  • Save dbyrne/424780 to your computer and use it in GitHub Desktop.
Save dbyrne/424780 to your computer and use it in GitHub Desktop.
Project Euler #2 - Ruby
fibs = Fiber.new do
x1, x2 = 1, 2
loop do
Fiber.yield x1
x1, x2 = x2, x2+x1
end
end
sum = 0
begin
sum += y if (y = fibs.resume).even?
end while y <= 4000000
puts sum
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment