Skip to content

Instantly share code, notes, and snippets.

@scottmagdalein
Last active December 11, 2015 23:48
Show Gist options
  • Save scottmagdalein/4679045 to your computer and use it in GitHub Desktop.
Save scottmagdalein/4679045 to your computer and use it in GitHub Desktop.
My answer to Project Euler Fibonacci problem here: http://projecteuler.net/problem=2
x = 1
y = 2
fib = Array.new
while x < 4_000_000 && y < 4_000_000
fib << x if x % 2 == 0
fib << y if y % 2 == 0
x += y
y += x
end
sum = 0
fib.each { |x| sum += x }
puts sum
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment