Skip to content

Instantly share code, notes, and snippets.

@aptinio
Created November 4, 2009 05:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aptinio/225807 to your computer and use it in GitHub Desktop.
Save aptinio/225807 to your computer and use it in GitHub Desktop.
Project Euler Problem 2
fib = [1, 2]
def fib.next
self[-1] + self[-2]
end
fib << fib.next while fib.next < 4_000_000
fib.select {|f| f.remainder(2) == 0}.reduce(:+)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment