Created
January 5, 2012 09:45
-
-
Save releu/1564460 to your computer and use it in GitHub Desktop.
Project Euler #2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Array | |
def sum | |
inject(0) { |s, i| s + i } | |
end | |
end | |
array = [1, 2] | |
while array.last < 4000000 | |
array << array[-2, 2].sum | |
end | |
puts array.select(&:even?).sum |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment